pybop.plot.standard_plots#

Attributes#

Classes#

StandardPlot

A class for creating and displaying interactive Plotly figures.

StandardSubplot

A class for creating and displaying a set of interactive Plotly figures in a grid layout.

Functions#

trajectories(x, y[, trace_names, show])

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

static wrap_text(text, width)[source]#

Wrap text to a specified width with HTML line breaks.

Parameters:
  • text (str) – The text to wrap.

  • width (int) – The width to wrap the text to.

Returns:

The wrapped text.

Return type:

str

go = None[source]#
layout = None[source]#
trace_name_width = 40[source]#
trace_options[source]#
traces = [][source]#
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: StandardPlot

A 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

__call__(show)[source]#

Generate and show the set of figures.

Parameters:

show (bool, optional) – If True, the figure is shown upon creation (default: True).

axis_titles = None[source]#
make_subplots = None[source]#
num_cols = None[source]#
num_rows = None[source]#
num_traces = 0[source]#
subplot_options[source]#
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”, “titlefont_size”: 18}.

Returns:

The Plotly figure object for the scatter plot.

Return type:

plotly.graph_objs.Figure

pybop.plot.standard_plots.DEFAULT_LAYOUT_OPTIONS[source]#
pybop.plot.standard_plots.DEFAULT_SUBPLOT_OPTIONS[source]#
pybop.plot.standard_plots.DEFAULT_SUBPLOT_TRACE_OPTIONS[source]#
pybop.plot.standard_plots.DEFAULT_TRACE_OPTIONS[source]#