Skip to content

fly_ruler_std.runtime.plot ​

本页由 fr-docs-dev gen-api 从源码 docstring 生成,请勿手工编辑;重新生成执行 just api。

Python定义曲线、浏览器编辑呈现的交互绘图工具。

公开成员 ​

名称类型定义位置
View类本页
Panel类本页
CurveStyle类本页
PanelConfig类本页
Presentation类本页
start函数本页
serve函数本页

定义 ​

View ​

python
class View(*, columns: int = 2)

使用具名面板构建绘图;没有隐式当前图或坐标轴。

参数

名称类型默认值说明
columnsint2网格列数,1至4。

__init__ ​

python
def __init__(*, columns: int = 2) -> None

设置网格列数并初始化空视图。

参数

名称类型默认值说明
columnsint2网格列数,1至4。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:155

panel ​

python
def panel(id: str, *, title: str = '', x_label: str = '', y_label: str = '', x_link: str | None = None) -> Panel

新增具名面板;重复标识报错。

参数

名称类型默认值说明
idstr—唯一面板标识。
titlestr''显示标题。
x_labelstr''横轴名称及单位。
y_labelstr''左纵轴名称及单位。
x_linkstr | NoneNone可选横轴联动组,同组须使用相同单位。

返回

类型说明
Panel可登记曲线的面板句柄。

异常

类型说明
ValueError面板标识重复或配置无效。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:165

presentation ​

python
presentation: Presentation

返回独立呈现副本,修改副本不改变View。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:202

apply ​

python
def apply(presentation: Presentation) -> None

原子应用呈现;缺失曲线失败,新曲线保持原位置与样式。

参数

名称类型默认值说明
presentationPresentation—不含数据的目标呈现配置。

异常

类型说明
ValueError引用曲线缺失或面板/曲线归属重复;原视图不变。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:206

snapshot ​

python
def snapshot() -> tuple[Presentation, dict[str, CurveData]]

返回独立呈现和只读数组映射,用于固定服务快照。

返回

类型说明
tuple[Presentation, dict[str, CurveData]]独立呈现及按稳定标识索引的只读曲线数组。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:244

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:148

Panel ​

python
class Panel(view: View, id: str)

View内的具名面板句柄,通过View.panel创建。

参数

名称类型默认值说明
viewView—所属视图。
idstr—视图内唯一面板标识。

__init__ ​

python
def __init__(view: View, id: str) -> None

绑定所属View与面板标识;通常通过View.panel创建。

参数

名称类型默认值说明
viewView—所属视图。
idstr—面板唯一标识。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:261

id ​

python
id = id

视图内唯一的面板标识。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:269

line ​

python
def line(id: str, *, x: ArrayLike, y: ArrayLike, label: str = '', color_group: str | None = None, color: str | None = None, width: float = 2, line: Literal['solid', 'dashed', 'dotted'] = 'solid', marker: bool = False, step: Literal['start', 'middle', 'end'] | None = None) -> None

登记等长一维XY快照,不排序、不插值;NaN/Inf表示断点。

参数

名称类型默认值说明
idstr—全View唯一的稳定曲线标识。
xArrayLike—横轴一维数值数组或序列。
yArrayLike—等长纵轴数值数组或序列。
labelstr''图例与列表显示标签,默认使用id。
color_groupstr | NoneNone可选默认同色分组,不强制后续联动改色。
colorstr | NoneNone显式颜色,覆盖分组默认值。
widthfloat2线宽,单位为像素。
lineLiteral['solid', 'dashed', 'dotted']'solid'实线、虚线或点线。
markerboolFalse是否显示样本标记。
stepLiteral['start', 'middle', 'end'] | NoneNone阶梯连接位置,None表示普通折线。

异常

类型说明
ValueError所属面板已移除、空或重复标识、数组维度/长度不匹配、样式无效。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:272

record_line ​

python
def record_line(id: str, *, source: Loader | Recorder, y: str, batch: int | None = None, x: str = 'time', label: str = '', color_group: str | None = None) -> None

按完整记录列画线;多batch必须显式选择,内存Recorder无需落盘。

参数

名称类型默认值说明
idstr—全View唯一曲线标识。
sourceLoader | Recorder—Loader或内存Recorder。
ystr—完整纵轴列名,向量分量显式选择。
batchint | NoneNone轨迹编号;仅单batch记录可省略。
xstr'time'完整横轴列名,默认time。
labelstr''显示标签。
color_groupstr | NoneNone默认同色分组。

异常

类型说明
ValueErrorbatch缺失、不存在或曲线输入无效。
polars.exceptions.ColumnNotFoundError指定记录列不存在。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:339

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:253

CurveStyle ​

python
class CurveStyle(BaseModel)

曲线显示属性;独立于数据和面板归属。

model_config ​

python
model_config = ConfigDict(extra='forbid', frozen=True)

Pydantic配置:拒绝未知字段并禁止属性重绑定。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:21

label ​

python
label: str = ''

显示标签,不用作曲线身份。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:23

color ​

python
color: str = '#2563eb'

实际显示颜色。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:25

width ​

python
width: float = 2

线宽,单位为像素。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:27

line ​

python
line: Literal['solid', 'dashed', 'dotted'] = 'solid'

折线样式:solid、dashed或dotted。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:29

marker ​

python
marker: bool = False

是否显示样本标记。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:31

step ​

python
step: Literal['start', 'middle', 'end'] | None = None

阶梯位置;None使用普通折线。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:33

visible ​

python
visible: bool = True

曲线是否可见。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:35

axis ​

python
axis: Literal['left', 'right'] = 'left'

曲线使用左侧或右侧纵轴。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:37

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:18

PanelConfig ​

python
class PanelConfig(BaseModel)

面板布局、坐标轴及包含曲线的有序标识。

model_config ​

python
model_config = ConfigDict(extra='forbid', frozen=True)

Pydantic配置:拒绝未知字段并禁止属性重绑定。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:44

id ​

python
id: str

视图内唯一面板标识。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:46

curves ​

python
curves: list[str] = []

按稳定曲线标识索引的样式,或面板内有序曲线标识。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:48

title ​

python
title: str = ''

面板标题。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:50

x_label ​

python
x_label: str = ''

横轴名称及单位。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:52

y_label ​

python
y_label: str = ''

左纵轴名称及单位。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:54

right_label ​

python
right_label: str = ''

右纵轴名称及单位。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:56

python
x_link: str | None = None

横轴联动组,None表示独立。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:58

legend ​

python
legend: bool = True

是否显示图例。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:60

height ​

python
height: int = 340

面板高度,单位为像素。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:62

x_min ​

python
x_min: float | None = None

可选横轴下界;对数刻度时必须大于零。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:64

x_max ​

python
x_max: float | None = None

可选横轴上界;对数刻度时必须大于零。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:66

y_min ​

python
y_min: float | None = None

可选左纵轴下界。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:68

y_max ​

python
y_max: float | None = None

可选左纵轴上界。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:70

right_min ​

python
right_min: float | None = None

可选右纵轴下界。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:72

right_max ​

python
right_max: float | None = None

可选右纵轴上界。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:74

x_scale ​

python
x_scale: Literal['linear', 'log'] = 'linear'

横轴线性或对数刻度。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:76

y_scale ​

python
y_scale: Literal['linear', 'log'] = 'linear'

左纵轴线性或对数刻度。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:78

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:41

Presentation ​

python
class Presentation(BaseModel)

不含数据的最终呈现;可导出为Python对象后应用到新的数组。

model_config ​

python
model_config = ConfigDict(extra='forbid', frozen=True)

Pydantic配置:拒绝未知字段并禁止属性重绑定。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:101

panels ​

python
panels: list[PanelConfig] = []

按显示顺序排列的面板配置。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:103

curves ​

python
curves: dict[str, CurveStyle] = {}

按稳定曲线标识索引的样式,或面板内有序曲线标识。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:105

columns ​

python
columns: int = 2

网格列数,范围为1至4。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:107

python ​

python
def python() -> str

导出可读Python构造代码,不包含数据或分析脚本。

返回

类型说明
str可保存并导入的Python源码,定义presentation变量。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:119

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/model.py:98

start ​

python
def start(view: View, *, host: str = '127.0.0.1', port: int = 0, open_browser: bool = True) -> _WebServer

后台启动固定快照,服务就绪后返回url/close/上下文句柄。

参数

名称类型默认值说明
viewView—已登记曲线的View,启动时冻结快照。
hoststr'127.0.0.1'监听地址,默认仅本机。
portint0监听端口,0由系统分配,固定端口冲突直接报错。
open_browserboolTrue就绪后是否打开浏览器。

返回

类型说明
_WebServer具有url、close与上下文管理能力的就绪服务句柄。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/server.py:9

serve ​

python
def serve(view: View, *, host: str = '127.0.0.1', port: int = 18000, open_browser: bool = True) -> None

阻塞查看,Ctrl+C释放服务并返回,不退出调用进程。

参数

名称类型默认值说明
viewView—已登记曲线的View,启动时冻结快照。
hoststr'127.0.0.1'监听地址,默认仅本机。
portint18000监听端口,0由系统分配,固定端口冲突直接报错。
open_browserboolTrue就绪后是否打开浏览器。

实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/server.py:32