pybop.plot.util#

Functions#

get_backend([backend])

Get instance of PlotBackend class for a given plotting backend

get_backend_from_figure([backend, figures])

Get instance of PlotBackend class from a provided figure or from a specified backend.

parse_data(x, y)

Check the type and dimensions of the data and convert if necessary to a list

remove_brackets(s)

Remove square brackets from a string and replace with forward slashes

use_backend(backend)

Select a plotting backend to be used for all subsequent plots.

wrap_text(text, width[, backend])

Wrap text to a specified width with HTML line breaks.

Module Contents#

pybop.plot.util.get_backend(backend=None)[source]#

Get instance of PlotBackend class for a given plotting backend

Parameters:

backend (str or pybop.plot.backends.PlotBackend, optional) – The plotting backend to be used (default: pybop.plot.current_backend)

pybop.plot.util.get_backend_from_figure(backend=None, figures=None)[source]#

Get instance of PlotBackend class from a provided figure or from a specified backend. If both are provided, the figure’s backend takes precedence.

Parameters:
  • backend (str or pybop.plot.backends.PlotBackend, optional) – The plotting backend to be used (default: pybop.plot.current_backend)

  • figures (figure object, optional) – Figure for plotting. If not provided a new figure is created

Returns:

Instance of the selected plotting backend.

Return type:

pybop.plot.backends.PlotBackend

pybop.plot.util.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.

pybop.plot.util.remove_brackets(s)[source]#

Remove square brackets from a string and replace with forward slashes as per section 7.1 of the SI Handbook

pybop.plot.util.use_backend(backend)[source]#

Select a plotting backend to be used for all subsequent plots.

Parameters:

backend (str or pybop.plot.backends.PlotBackend) – The plotting backend to be used.

pybop.plot.util.wrap_text(text, width, backend='matplotlib')[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