perda.plotting.subplots#
- perda.plotting.subplots.data_instance_subplots(rows, title=None, row_y_labels=None, show_legend=True, layout_config=LayoutConfig(width=1200, height=700, margin={'l': 70, 'r': 50, 't': 90, 'b': 70}, plot_bgcolor='white', title_x=0.5, title_xanchor='center', title_yanchor='top', grid_width_per_col=400, grid_height_per_row=350, grid_horizontal_spacing=0.08, grid_vertical_spacing=0.12, max_display_resolution=50), font_config=FontConfig(large=20, medium=14, small=10), timestamp_unit=Timescale.MS)[source]#
Plot groups of DataInstances as stacked subplots on a shared time axis.
Each element of
rowsbecomes one subplot row. Multiple DataInstances in the same row are overlaid on that row’s y-axis — useful for comparing signals that share the same units or scale.- Parameters:
rows (List[List[DataInstance]]) – Outer list defines subplot rows (top to bottom); inner list defines the DataInstances overlaid within that row.
title (str | None, optional) – Figure-level title. Default is None (no title).
row_y_labels (List[str | None] | None, optional) – Y-axis label for each row. Must match the length of
rowswhen provided.Noneentries fall back to auto-labelling from the DataInstance labels in that row. Default is None (all rows auto-label).show_legend (bool, optional) – Whether to show the figure legend. Default is True.
layout_config (LayoutConfig, optional) – Dimensions, spacing, and style for the subplot grid.
font_config (FontConfig, optional) – Font sizes for title, axis labels, tick labels, and legend.
timestamp_unit (Timescale, optional) – Timestamp unit of the underlying DataInstances. Converted to seconds for x-axis display. Default is Timescale.MS.
- Returns:
Plotly figure containing the stacked subplot grid.
- Return type:
go.Figure
Examples
>>> fig = data_instance_subplots( ... rows=[[speed_di], [torque_di, motor_di]], ... title="Run Overview", ... row_y_labels=["Speed (mph)", "Torque / Motor"], ... ) >>> fig.show()
- perda.plotting.subplots.plot_multi_log_subplots(logs, var_names, row_y_labels=None, title=None, layout_config=LayoutConfig(width=1200, height=700, margin={'l': 70, 'r': 50, 't': 90, 'b': 70}, plot_bgcolor='white', title_x=0.5, title_xanchor='center', title_yanchor='top', grid_width_per_col=400, grid_height_per_row=350, grid_horizontal_spacing=0.08, grid_vertical_spacing=0.12, max_display_resolution=50), font_config=FontConfig(large=20, medium=14, small=10), timestamp_unit=Timescale.MS)[source]#
Plot the same set of variables across multiple logs as stacked subplots, with each variable on one subplot.
- Parameters:
logs (List[SingleRunData])
var_names (List[str]) – Ordered list of variable names to plot, one per subplot row. Variables absent from log are silently skipped.
row_y_labels (List[str | None] | None, optional) – Y-axis label for each row. Must match the length of
var_namestitle (str | None, optional) – Base figure title. When multiple figures are produced a
(1/N)suffix is appended automatically.layout_config (LayoutConfig, optional)
font_config (FontConfig, optional)
timestamp_unit (Timescale, optional) – Timestamp unit of the underlying DataInstances. Default is Timescale.MS.
- Returns:
The combined figure with all subplots.
- Return type:
go.Figure
Examples
>>> fig = plot_multi_log_subplots( ... logs=[aly1.data, aly2.data], ... var_names=["pcm."pcm.wheelSpeeds.frontLeft", "ludwig.steeringWheel.angle", "pcm.pedals.brakePressure.front"], ... title="Speed Comparison", ... ) >>> fig.show()
- perda.plotting.subplots.stride_downsample(timestamps_s, values, max_display_resolution)[source]#
Return stride-downsampled arrays capped at max_display_resolution.
- Parameters:
timestamps_s (np.ndarray) – Time values in seconds.
values (np.ndarray) – Corresponding sample values.
max_display_resolution (float) – Target display sample rate.
- Returns:
Downsampled
(timestamps_s, values).- Return type:
Tuple[np.ndarray, np.ndarray]