pybop.plot.standard_plots#
Attributes#
Classes#
A class for creating and displaying interactive Plotly figures. |
|
A class for creating and displaying a set of interactive Plotly figures in a grid layout. |
Functions#
|
Quickly plot one or more trajectories using Plotly. |
Module Contents#
- class pybop.plot.standard_plots.StandardPlot(x=None, y=None, layout=None, layout_options=None, trace_options=None, trace_names=None, trace_name_width=40)[source]#
A class for creating and displaying interactive Plotly figures.
- Parameters:
x (list or np.ndarray, optional) – X-axis data points.
y (list or np.ndarray, optional) – Primary Y-axis data points for simulated model output.
layout (Plotly layout, optional) – A layout for the figure, overrides the layout options (default: None).
layout_options (dict, optional) – Settings to modify the default layout (default: DEFAULT_LAYOUT_OPTIONS).
trace_options (dict, optional) – Settings to modify the default trace type (default: DEFAULT_TRACE_OPTIONS).
trace_names (str, optional) – Name(s) for the primary trace(s) (default: None).
trace_name_width (int, optional) – Maximum length of the trace names before text wrapping is used (default: 40).
- Returns:
The generated Plotly figure.
- Return type:
plotly.graph_objs.Figure
- __call__(show=True)[source]#
Generate and show the figure.
- Parameters:
show (bool, optional) – If True, the figure is shown upon creation (default: True).
- add_traces(x, y, trace_names=None, **trace_options)[source]#
Add a set of traces to the plot dictionary.
- Parameters:
x (list or np.ndarray) – X-axis data points.
y (list or np.ndarray) – Primary Y-axis data points for simulated model output.
trace_names (str or list[str], optional) – Name(s) for the primary trace(s) (default: None).
- create_trace(x, y, **trace_options)[source]#
Create a trace for the Plotly figure.
- Returns:
A trace for a Plotly figure.
- Return type:
plotly.graph_objs.Scatter
- parse_data(x, y)[source]#
Check the type and dimensions of the data and convert if necessary to a list of ‘things plotly can take’, e.g. numpy arrays or lists of numbers.
- Parameters:
x (list or np.ndarray, optional) – X-axis data points.
y (list or np.ndarray, optional) – Primary Y-axis data points for simulated model output.
- static remove_brackets(s)[source]#
Remove square brackets from a string and replace with forward slashes as per section 7.1 of the SI Handbook
- class pybop.plot.standard_plots.StandardSubplot(x, y, num_rows=None, num_cols=None, axis_titles=None, layout=None, layout_options=DEFAULT_LAYOUT_OPTIONS, subplot_options=DEFAULT_SUBPLOT_OPTIONS, trace_options=DEFAULT_SUBPLOT_TRACE_OPTIONS, trace_names=None, trace_name_width=40)[source]#
Bases:
StandardPlotA class for creating and displaying a set of interactive Plotly figures in a grid layout.
- Parameters:
x (list or np.ndarray) – X-axis data points.
y (list or np.ndarray) – Primary Y-axis data points for simulated model output.
num_rows (int, optional) – Number of rows of subplots, can be set automatically (default: None).
num_cols (int, optional) – Number of columns of subplots, can be set automatically (default: None).
layout (Plotly layout, optional) – A layout for the figure, overrides the layout options (default: None).
layout_options (dict, optional) – Settings to modify the default layout (default: DEFAULT_LAYOUT_OPTIONS).
trace_options (dict, optional) – Settings to modify the default trace type (default: DEFAULT_TRACE_OPTIONS).
trace_names (str, optional) – Name(s) for the primary trace(s) (default: None).
trace_name_width (int, optional) – Maximum length of the trace names before text wrapping is used (default: 40).
- Returns:
The generated Plotly figure.
- Return type:
plotly.graph_objs.Figure
- pybop.plot.standard_plots.trajectories(x, y, trace_names=None, show=True, **layout_kwargs)[source]#
Quickly plot one or more trajectories using Plotly.
- Parameters:
x (list or np.ndarray) – X-axis data points.
y (list or np.ndarray) – Y-axis data points for each trajectory.
trace_names (list or str, optional) – Name(s) for the trace(s) (default: None).
**layout_kwargs (optional) – Valid Plotly layout keys and their values, e.g. xaxis_title=”Time / s” or xaxis={“title”: “Time [s]”, font={“size”:14}}
- Returns:
The Plotly figure object for the scatter plot.
- Return type:
plotly.graph_objs.Figure