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)使用具名面板构建绘图;没有隐式当前图或坐标轴。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
columns | int | 2 | 网格列数,1至4。 |
__init__
python
def __init__(*, columns: int = 2) -> None设置网格列数并初始化空视图。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
columns | int | 2 | 网格列数,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新增具名面板;重复标识报错。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | str | — | 唯一面板标识。 |
title | str | '' | 显示标题。 |
x_label | str | '' | 横轴名称及单位。 |
y_label | str | '' | 左纵轴名称及单位。 |
x_link | str | None | None | 可选横轴联动组,同组须使用相同单位。 |
返回
| 类型 | 说明 |
|---|---|
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原子应用呈现;缺失曲线失败,新曲线保持原位置与样式。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
presentation | Presentation | — | 不含数据的目标呈现配置。 |
异常
| 类型 | 说明 |
|---|---|
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创建。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
view | View | — | 所属视图。 |
id | str | — | 视图内唯一面板标识。 |
__init__
python
def __init__(view: View, id: str) -> None绑定所属View与面板标识;通常通过View.panel创建。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
view | View | — | 所属视图。 |
id | str | — | 面板唯一标识。 |
实现位置: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表示断点。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | str | — | 全View唯一的稳定曲线标识。 |
x | ArrayLike | — | 横轴一维数值数组或序列。 |
y | ArrayLike | — | 等长纵轴数值数组或序列。 |
label | str | '' | 图例与列表显示标签,默认使用id。 |
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表示普通折线。 |
异常
| 类型 | 说明 |
|---|---|
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无需落盘。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | str | — | 全View唯一曲线标识。 |
source | Loader | Recorder | — | Loader或内存Recorder。 |
y | str | — | 完整纵轴列名,向量分量显式选择。 |
batch | int | None | None | 轨迹编号;仅单batch记录可省略。 |
x | str | 'time' | 完整横轴列名,默认time。 |
label | str | '' | 显示标签。 |
color_group | str | None | None | 默认同色分组。 |
异常
| 类型 | 说明 |
|---|---|
ValueError | batch缺失、不存在或曲线输入无效。 |
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
x_link
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, print_url: bool = False) -> _WebServer后台启动固定快照,服务就绪后返回url/close/上下文句柄。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
view | View | — | 已登记曲线的View,启动时冻结快照。 |
host | str | '127.0.0.1' | 监听地址,默认仅本机。 |
port | int | 0 | 监听端口,0由系统分配,固定端口冲突直接报错。 |
open_browser | bool | True | 就绪后是否打开浏览器。 |
print_url | bool | False | 就绪后是否向标准错误输出一行实际访问地址。 |
返回
| 类型 | 说明 |
|---|---|
_WebServer | 具有url、close与上下文管理能力的就绪服务句柄。 |
实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/server.py:15
serve
python
def serve(view: View, *, host: str = '127.0.0.1', port: int = 18000, open_browser: bool = True, print_url: bool = False) -> None阻塞查看,Ctrl+C释放服务并返回,不退出调用进程。
参数
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
view | View | — | 已登记曲线的View,启动时冻结快照。 |
host | str | '127.0.0.1' | 监听地址,默认仅本机。 |
port | int | 18000 | 监听端口,0由系统分配,固定端口冲突直接报错。 |
open_browser | bool | True | 就绪后是否打开浏览器。 |
print_url | bool | False | 就绪后是否向标准错误输出一行实际访问地址。 |
实现位置:packages/fly_ruler/python/fly_ruler_std/runtime/plot/server.py:45