pybop.plot.backends#
Submodules#
Classes#
Matplotlib implementation of the PlotBackend interface. |
|
Abstract base class defining a plotting backend interface. |
|
Plotly implementation of the PlotBackend interface. |
|
Manages the installation and configuration of Plotly for generating visualizations. |
Package Contents#
- class pybop.plot.backends.MatplotlibBackend[source]#
Bases:
pybop.plot.backends.base.PlotBackendMatplotlib implementation of the PlotBackend interface. This backend converts backend-agnostic trace definitions into Matplotlib figures, axes, and artists. Plot objects are represented as dictionaries containing plotting arguments and metadata, allowing higher-level plotting code to remain independent of the underlying plotting library.
- _figsize(style)[source]#
Convert pixel-based width and height values from a style dictionary into a Matplotlib figsize (inches).
- colorbar(fig, data, colorscale='viridis', label=None, ax=None)[source]#
Add colourbar to figure
- Parameters:
fig (matplotlib.figure.Figure) – The figure.
data (array-like) – The data to be mapped
scale (str) – Name of the colormap
label (str, optional) – label to be displayed alongside colorbar
ax (matplotlib axis object, optional) – Specity an axis for plotting. Otherwise current axis is used.
- contour_plot(x, y, z, fig, ax=None, colorscale='viridis')[source]#
Return trace definitions for a filled contour plot and contour lines.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Surface values.
colorscale (str, optional) – Colour scale name.
fig (matplotlib.figure.Figure) – The figure.
ax (matplotlib axis object, optional) – Specity an axis for plotting. Otherwise current axis is used.
- Returns:
dictionary for contour plot definition and dictionary for contour line definition
- Return type:
object
- create_figure(title=None, xaxis_title=None, yaxis_title=None, traces=None, style=None)[source]#
Create a single-axis figure and optionally populate it with traces.
- Parameters:
title (str, optional) – Figure title.
xaxis_title (str, optional) – X-axis label.
yaxis_title (str, optional) – Y-axis label.
traces (list[dict], optional) – Trace definitions to plot immediately.
style (dict, optional) –
Figure styling options. Currently supported options:
width in pixels
heith in pixels
xaxis_range: range of the X-axis
yaxis_range: range of the Y-axis
bg_color: background color of the axis
- Returns:
Configured figure instance.
- Return type:
matplotlib.figure.Figure
- fill_between(x, y_upper, y_lower, color)[source]#
Return a trace definition for a filled region between two curves.
- Parameters:
x (array-like) – X-axis values.
y_upper (array-like) – Upper boundary values.
y_lower (array-like) – Lower boundary values.
color (str) – Fill colour.
- heatmap(x, y, z, colorscale='viridis')[source]#
Return a trace definition for a heatmap.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Surface values.
colorscale (str, optional) – Colour scale name.
- histogram_plot(x, name, style: dict = None)[source]#
Return a trace definition for a histogram.
- Parameters:
x (array-like) – Data to bin.
name (str) – Histogram label.
style (dict, optional) – Currently only ‘alpha’ supported for opacity. All other style arguments ignored.
- legend(fig, axes=None, style: dict = None)[source]#
Create an axis-level or figure-level legend.
Supports legends positioned outside the plotting area and updates the layout rectangle used by tight_layout() accordingly.
- Parameters:
fig (matplotlib.figure.Figure) – The figure object
style (dict, optional) –
Legend styling options. Currently supported options:
loc: str
coords: tuple - is translated into bbox_to_anchor
- outside: tuple(sidestr, offset: float) places
the legend outside the plot, where the side (left, right, top, bottom) determines on wich side of the plot the legend is placed and the offset determines the fraction of the figure height or width reserved for the legend. Overrides loc and coords.
- fig_legend: if true, one legend is created for the entire figure, otherwise the legend is created
for the current axis.
- line(x=None, y=None, label=None, style=None)[source]#
Return a trace definition for a line plot.
- Parameters:
x (array-like, optional) – Coordinates of the line. If both x and y are provided, the shorter sequence determines the plotted length.
y (array-like, optional) – Coordinates of the line. If both x and y are provided, the shorter sequence determines the plotted length.
label (str, optional) – Trace label.
style (dict, optional) – Line styling options.
- Returns:
dictionary with positional argumetns, label and style arguments
- Return type:
object
- make_subplots(num_rows: int, num_cols: int, num_plots: int, title=None, style=None)[source]#
Create a figure containing multiple subplot axes in a grid.
- Parameters:
num_rows (int) – Number of rows in the subplot grid.
num_cols (int) – Number of columns in the subplot grid.
num_plots (int) – Total number of subplots to create.
title (str, optional) – Figure title.
style (dict, optional) –
Figure styling options. Currently supported options:
width in pixels
heith in pixels
bg_color: background color of the axis
- Returns:
Configured figure instance.
- Return type:
matplotlib.figure.Figure
- plot_trace(traces: dict | list[dict], fig, ax=None)[source]#
Convert one or more trace definitions into Matplotlib plotting calls.
- Parameters:
traces (dict or list[dict]) – Each trace dictionary specifies a plotting method, positional arguments, and keyword arguments compatible with a Matplotlib Axes method.
fig (matplotlib.figure.Figure) – The figure object
ax (matplotlib axis object, optional) – Specity an axis for plotting. Otherwise current axis is used.
- sample_color_scale(data, scale='viridis', d_min=None, d_max=None)[source]#
Map data values to RGBA colours using a Matplotlib colormap.
- Parameters:
data (ndarray) – The data to be mapped
scale (str) – Name of the colormap
d_min (float, optional) – Minimum value to be mapped. Otherwise the minimum of the data is used.
d_max (float, optional) – Maximum value to be mapped. Ohterwise maximum of the data is used.
- scatter(x, y, colors=None, labels=None, colorscale='Greys')[source]#
Return a trace definition for a scatter plot.
- Parameters:
x (array-like) – Point coordinates.
y (array-like) – Point coordinates.
colors (array-like) – Values or colours associated with each point.
labels (array-like, optional) – Point labels. Point labels are ignored by matplotlib implementation. Argument retained for consistency with plotly.
colorscale (str, optional) – Colour scale name.
- show_figure(fig)[source]#
Apply final layout adjustments and display the figure.
- Parameters:
fig (matplotlib.figure.Figure) – The figure object
- show_table(header, values, title, fig=None, ax=None)[source]#
Display tabular data in a standalone Matplotlib figure.
Array-valued entries are converted to comma-separated strings before rendering.
- Parameters:
header (list) – Column headers.
values (list) – Table contents.
title (str) – Table title.
fig (matplotlib.figure.Figure, optional) – Figure for plotting. If not provided a new figure is created.
ax (matplotlib axis object, optional) – Axis for plotting. If not provided the current axis is used.
- update_axes_ranges(fig, ax=None, xaxis_range=None, yaxis_range=None)[source]#
Update the ranges of the axes in the provided figure.
- Parameters:
fig (Figure) – Matplotlib figure containing the axes to update.
ax (tuple) – Subplot location.
xaxis_range (tuple) – Range for the x-axis.
yaxis_range (tuple) – Range for the y-axis.
- update_axes_titles(figures, axes, xaxis_titles, yaxis_titles, max_width=40)[source]#
Update the titles of the axes in the provided figures.
- Parameters:
figures (list[Figure]) – List of matplotlib figures containing the axes to update.
axes (list[tuple]) – List of subplot locations specified as matplotlib axes objects.
xaxis_titles (list[str]) – List of titles for the X-axes.
yaxis_titles (list[str]) – List of titles for the Y-axes.
max_width (int, optional) – Maximum width for the axis titles before wrapping. Default is 40 characters.
- update_plot_titles(figures, axes, titles, max_text_width=40, pad=0)[source]#
Update the titles of the subplots in the provided figures.
- Parameters:
figures (list[Figure]) – List of matplotlib figures containing the subplots to update.
axes (list[tuple]) – List of subplot locations specified as matplotlib axes objects.
titles (list[str]) – List of titles for the subplots.
max_text_width (int, optional) – Maximum width for the subplot titles before wrapping. Default is 40 characters.
pad (int, optional) – Padding between the title and the subplot. Default is 0.
- vline(fig, x, style=None, ax=None)[source]#
Add a vertical reference line to the current axis.
- Parameters:
fig (matplotlib.figure.Figure) – The figure.
x (float) – The position of the vertical line on the axis
style (dict, optional) – matplotlib arguments for axvline method
ax (matplotlib axis object, optional) – Specity an axis for plotting. Otherwise current axis is used.
- colorcycle#
- global_colorcycle = False#
- mpl#
- plt#
- rect = [0, 0, 1, 1]#
- class pybop.plot.backends.PlotBackend[source]#
Bases:
abc.ABCAbstract base class defining a plotting backend interface.
Concrete implementations provide plotting functionality for a specific visualization library (e.g. Plotly, Matplotlib) while exposing a common API to the rest of the application.
Methods in this interface are responsible for creating figures, adding traces and annotations, generating specialised plot types, and rendering results.
- abstractmethod colorbar(fig, data, colorscale='viridis', label=None)[source]#
Add a colour bar representing a colour scale.
- Parameters:
fig (object) – Target figure.
data (array-like) – Data used for colour scaling.
colorscale (str, optional) – Colour scale name.
label (str, optional) – Colour bar label.
- abstractmethod contour_plot(x, y, z, fig, ax=None, colorscale='viridis')[source]#
Create a contour plot.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Surface values.
colorscale (str, optional) – Colour scale name.
fig (object) – Target figure.
ax (object, optional) – Target subplot axis.
- Returns:
Backend-specific contour trace or figure.
- Return type:
object
- abstractmethod create_figure(title: str = None, xaxis_title: str = None, yaxis_title: str = None, traces: list = None, style: dict = None)[source]#
Create and return a new figure.
- Parameters:
title (str, optional) – Figure title.
xaxis_title (str, optional) – X-axis label.
yaxis_title (str, optional) – Y-axis label.
traces (list, optional) – Initial traces to add to the figure.
style (dict, optional) – Backend-specific styling options.
- Returns:
Backend-specific figure object.
- Return type:
object
- abstractmethod fill_between(x, y_upper, y_lower, color)[source]#
Create a filled region between upper and lower bounds.
- Parameters:
x (array-like) – X-axis values.
y_upper (array-like) – Upper boundary values.
y_lower (array-like) – Lower boundary values.
color (str) – Fill colour.
- abstractmethod heatmap(x, y, z, colorscale='viridis')[source]#
Create a heatmap.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Heatmap values.
colorscale (str, optional) – Colour scale name.
- Returns:
Backend-specific heatmap trace or figure.
- Return type:
object
- abstractmethod histogram_plot(x, name, style=None)[source]#
Create a histogram.
- Parameters:
x (array-like) – Data to bin.
name (str) – Histogram label.
style (dict, optional) – Histogram styling options.
- abstractmethod legend(fig, ax=None, style: dict = None)[source]#
Configure or display a legend for a figure.
- Parameters:
fig (object) – Figure object.
style (dict, optional) – Legend styling options.
ax (object, optional) – Subplot axis to apply the legend to (if applicable).
- abstractmethod line(x=None, y=None, label=None, style=None)[source]#
Create a line plot trace.
- Parameters:
x (array-like, optional) – Coordinates of the line.
y (array-like, optional) – Coordinates of the line.
label (str, optional) – Trace label.
style (dict, optional) – Line styling options.
- Returns:
Backend-specific line trace.
- Return type:
object
- abstractmethod make_subplots(num_rows: int, num_cols: int, num_plots: int, title=None, style=None)[source]#
Create a figure containing multiple subplot axes.
- Parameters:
num_rows (int) – Number of rows in the subplot grid.
num_cols (int) – Number of columns in the subplot grid.
num_plots (int) – Total number of subplots to create.
title (str, optional) – Figure title.
style (dict, optional) – Backend-specific styling options.
- Returns:
fig (object) – Backend-specific figure object.
axes (list) – List of subplot axes.
- parse_input_axes(figures, axes, num_plots=None, allow_single_axis=True)[source]#
Parse and validate input figures and axes for plotting.
- Parameters:
figures (object or list) – Figure(s) to plot on.
axes (object or list) – Axis/axes to plot on.
num_plots (int, optional) – Expected number of axes for the plot.
allow_single_axis (bool, optional) – Whether to allow a single axis for multiple plots.
- Returns:
figures (list) – List of figure objects.
axes (list) – List of axis objects.
create_figure (bool) – Whether a new figure should be created.
single_axis (bool) – Whether a single axis is being used for multiple plots.
- abstractmethod plot_trace(traces: dict | list[dict], fig, ax=None, color_cycle=None)[source]#
Add one or more traces to a figure or subplot.
- Parameters:
traces (dict or list[dict]) – Trace definitions to plot.
fig (object) – Target figure.
ax (object, optional) – Target subplot axis.
color_cycle (iterable, optional) – Sequence of colours used when plotting multiple traces.
- abstractmethod sample_color_scale(data, scale='viridis', d_min=None, d_max=None)[source]#
Map data values onto a colour scale.
- Parameters:
data (array-like) – Values to colour-map.
scale (str, optional) – Colour scale name.
d_min (float, optional) – Lower bound for normalisation.
d_max (float, optional) – Upper bound for normalisation.
- Returns:
Colours corresponding to the supplied data.
- Return type:
array-like
- abstractmethod scatter(x, y, colors, labels=None, colorscale='Greys')[source]#
Create a scatter plot.
- Parameters:
x (array-like) – Point coordinates.
y (array-like) – Point coordinates.
colors (array-like) – Values or colours associated with each point.
labels (array-like, optional) – Point labels.
colorscale (str, optional) – Colour scale name.
- abstractmethod show_figure(fig)[source]#
Render or display a figure.
- Parameters:
fig (object) – Figure to display.
- abstractmethod show_table(header, values, title)[source]#
Display tabular data.
- Parameters:
header (list) – Column headers.
values (list) – Table contents.
title (str) – Table title.
- abstractmethod update_axes_ranges(fig, ax, xaxis_range, yaxis_range)[source]#
Update the ranges of the axes in the provided figure.
- Parameters:
fig (Figure) – Figure containing the axes to update.
ax (tuple) – Subplot location.
xaxis_range (tuple) – Range for the x-axis.
yaxis_range (tuple) – Range for the y-axis.
- abstractmethod update_axes_titles(figs, axes, xaxis_titles, yaxis_titles)[source]#
Update the titles of the axes in the provided figures.
- Parameters:
figures (list[Figure]) – List of figures containing the axes to update.
axes (list[tuple]) – List of subplot locations.
xaxis_titles (list[str]) – List of titles for the X-axes.
yaxis_titles (list[str]) – List of titles for the Y-axes.
max_width (int, optional) – Maximum width for the axis titles before wrapping. Default is 40 characters.
- abstractmethod update_plot_titles(figs, axes, titles, pad)[source]#
Update the titles of the subplots in the provided figures.
- Parameters:
figures (list[Figure]) – List of figures containing the subplots to update.
axes (list[tuple]) – List of subplot locations.
titles (list[str]) – List of titles for the subplots.
max_text_width (int, optional) – Maximum width for the subplot titles before wrapping. Default is 40 characters.
pad (int, optional) – Padding between the title and the subplot. Default is 0.
- abstractmethod vline(fig, x, style=None)[source]#
Add a vertical reference line to a figure.
- Parameters:
fig (object) – Target figure.
x (float) – X-coordinate of the line.
style (dict, optional) – Line styling options.
- property name#
Return the name of the backend.
- Returns:
Name of the backend.
- Return type:
str
- class pybop.plot.backends.PlotlyBackend[source]#
Bases:
pybop.plot.backends.base.PlotBackendPlotly implementation of the PlotBackend interface.
This backend converts backend-agnostic plot definitions into Plotly figures and traces, providing interactive visualisations while maintaining a common plotting API.
- static _check_axis_input(axis, raise_error=True)[source]#
Validate that the axis input is a tuple of two numbers.
- Parameters:
axis (tuple) – Axis input to validate.
- Raises:
ValueError – If the axis input is not a tuple of two numbers.
- _get_line_options(style, opts)[source]#
Populate Plotly line styling options.
- Parameters:
style (dict) – User-supplied style options.
opts (dict) – Trace options dictionary updated in-place.
- Return type:
None
- colorbar(fig, data, colorscale='viridis', label=None, ax=None)[source]#
Add a standalone colour bar to a figure.
- Parameters:
fig (plotly.graph_objects.Figure) – Target figure.
data (array-like) – Values defining the colour range.
colorscale (str, optional) – Plotly colour scale name.
label (str, optional) – Colour bar title.
- Return type:
None
- contour_plot(x, y, z, fig, ax, colorscale='viridis')[source]#
Create a contour plot trace.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Contour values.
colorscale (str, optional) – Plotly colour scale.
fig (plotly.graph_objects.Figure) – Target figure.
ax (tuple, optional) – Subplot location. If provided, the contour trace is added to the specified subplot.
- Returns:
Contour trace.
- Return type:
plotly.graph_objects.Contour
- create_figure(title: str = None, xaxis_title: str = None, yaxis_title: str = None, traces=None, style: dict = None)[source]#
Create a Plotly figure.
- Parameters:
title (str, optional) – Figure title.
xaxis_title (str, optional) – X-axis label.
yaxis_title (str, optional) – Y-axis label.
traces (list, optional) – Plotly traces to add to the figure.
style (dict, optional) –
- Currently supported options:
width in pixels
height in pixels
xaxis_range: range of the X-axis
yaxis_range: range of the Y-axis
bg_color: background color of the axis
- Returns:
Configured Plotly figure.
- Return type:
plotly.graph_objects.Figure
- fill_between(x, y_upper, y_lower, color)[source]#
Create a filled region between two curves.
- Parameters:
x (array-like) – X values.
y_upper (array-like) – Upper boundary.
y_lower (array-like) – Lower boundary.
color (str) – Fill colour.
- Returns:
Filled area trace.
- Return type:
plotly.graph_objects.Scatter
- heatmap(x, y, z, colorscale='viridis')[source]#
Create a heatmap trace.
- Parameters:
x (array-like) – Coordinate values.
y (array-like) – Coordinate values.
z (array-like) – Heatmap values.
colorscale (str, optional) – Plotly colour scale.
- Returns:
Heatmap trace.
- Return type:
plotly.graph_objects.Heatmap
- histogram_plot(x, name, style=None)[source]#
Create a histogram trace.
- Parameters:
x (array-like) – Data values.
name (str) – Histogram label.
style (dict, optional) – Histogram styling options.
- Returns:
Histogram trace.
- Return type:
plotly.graph_objects.Histogram
- legend(fig, axes=None, style: dict = None)[source]#
Configure and display a figure legend.
- Parameters:
fig (plotly.graph_objects.Figure) – Target figure.
style (dict, optional) – Legend styling options including orientation, location and anchor coordinates.
axes (tuple, optional) – Subplot axis to apply the legend to (if applicable).
- line(x=None, y=None, label=None, style=None)[source]#
Create a line and/or marker trace.
- Parameters:
x (array-like, optional) – X values.
y (array-like) – Y values.
label (str, optional) – Legend label.
style (dict, optional) –
Line and marker styling options. Currently supported:
linestyle: see LINESTYLE_MAP
linewidth
color
marker: the marker symbol see MARKER_MAP
markerfacecolor
markeredgecolor
markeredgewidth
fillstyle (for marker)
- Returns:
Scatter trace configured as a line, marker plot, or combined line-marker plot.
- Return type:
plotly.graph_objects.Scatter
- make_subplots(num_rows: int, num_cols: int, num_plots: int, title=None, style=None)[source]#
Create a figure containing multiple subplots.
- Parameters:
num_rows (int) – Number of rows in the subplot grid.
num_cols (int) – Number of columns in the subplot grid.
num_plots (int) – Total number of subplots to create.
title (str, optional) – Figure title.
xaxis_titles (str or list[str], optional) – X-axis titles.
yaxis_titles (str or list[str], optional) – Y-axis titles.
style (dict, optional) – Figure styling options.
- Returns:
- (
figure, axes dictionary, number of rows, number of columns
)
- Return type:
tuple
- parse_input_axes(figures, axes, num_plots=None, allow_single_axis=True)[source]#
Parse and validate the input axes for plotting.
- Parameters:
figures (Figure or list[Figure]) – Plotly figure(s) to which the axes belong.
axes (tuple or list[tuple]) – Subplot locations specified as (row, col) tuples.
num_plots (int, optional) – Number of plots to be displayed.
allow_single_axis (bool, optional) – If True, a single axis can be used for all plots.
- Returns:
tuple –
- (
list of figures, list of axes, number of rows, number of columns
)
Raises
- plot_trace(traces, fig, ax=None)[source]#
Add one or more traces to a figure or subplot.
- Parameters:
traces (Trace or list[Trace]) – Plotly trace objects to add.
fig (plotly.graph_objects.Figure) – Target figure.
ax (tuple, optional) – Subplot location. If provided, traces are added to the specified subplot.
- Return type:
None
- sample_color_scale(data, scale='viridis', d_min=None, d_max=None)[source]#
Sample colours from a Plotly colour scale.
- Parameters:
data (array-like) – Values to map onto the colour scale.
scale (str, optional) – Plotly colour scale name.
d_min (float, optional) – Minimum value used for normalisation.
d_max (float, optional) – Maximum value used for normalisation.
- Returns:
Colours corresponding to the supplied values.
- Return type:
list
- scatter(x, y, colors, labels=None, colorscale='Greys')[source]#
Create a scatter plot trace.
- Parameters:
x (array-like) – Point coordinates.
y (array-like) – Point coordinates.
colors (array-like) – Values used to colour markers.
labels (array-like, optional) – Hover labels.
colorscale (str, optional) – Plotly colour scale.
- Returns:
Scatter trace.
- Return type:
plotly.graph_objects.Scatter
- show_figure(fig)[source]#
Display one or more Plotly figures.
- Parameters:
fig (Figure or iterable[Figure]) – Figure or collection of figures to display.
- show_table(header, values, title, fig=None, ax=None)[source]#
Display tabular data as a Plotly table.
- Parameters:
header (list) – Column headers.
values (list) – Table contents.
title (str) – Table title.
fig (plotly.graph_objects.Figure, optional) – Figure for plotting. If not provided a new figure is created.
ax (tuple, optional) – Subplot location. If provided, the table is added to the specified subplot.
- Returns:
None
NOTE (There seems to be a bug in plotly https://github.com/plotly/plotly.py/issues/3424)
If any plot with a vline is added to a figure with subplots AFTER a table was added,
this may cause an error. This can be avoided by always adding any tables last.
- update_axes_ranges(fig, ax, xaxis_range, yaxis_range)[source]#
Update the ranges of the axes in the provided figure.
- Parameters:
fig (Figure) – Plotly figure containing the axes to update.
ax (tuple) – Subplot location.
xaxis_range (tuple) – Range for the x-axis.
yaxis_range (tuple) – Range for the y-axis.
- update_axes_titles(figures, axes, xaxis_titles, yaxis_titles, max_width=40)[source]#
Update the titles of the axes in the provided figures.
- Parameters:
figures (list[Figure]) – List of plotly figures containing the axes to update.
axes (list[tuple]) – List of subplot locations specified as (row, col) tuples.
xaxis_titles (list[str]) – List of titles for the X-axes.
yaxis_titles (list[str]) – List of titles for the Y-axes.
max_width (int, optional) – Maximum width for the axis titles before wrapping. Default is 40 characters.
- update_plot_titles(figures, axes, titles, max_text_width=40, pad=0)[source]#
Update the titles of the subplots in the provided figures.
- Parameters:
figures (list[Figure]) – List of plotly figures containing the subplots to update.
axes (list[tuple]) – List of subplot locations specified as (row, col) tuples.
titles (list[str]) – List of titles for the subplots.
max_text_width (int, optional) – Maximum width for the subplot titles before wrapping. Default is 40 characters.
pad (int, optional) – Padding between the title and the subplot. Default is 0. Ignored for plotly. Added for consistency with matplotlib backend.
- vline(fig, x, style=None, ax=None)[source]#
Add a vertical reference line to a figure.
- Parameters:
fig (plotly.graph_objects.Figure) – Target figure.
x (float) – X-coordinate of the line.
style (dict, optional) – Line styling options.
ax (tuple, optional) – Subplot location. If provided, the line is added to the specified subplot.
- Returns:
None
NOTE (There seems to be a bug in plotly https://github.com/plotly/plotly.py/issues/3424) – If any plot with a vline is added to a figure with subplots AFTER a table was added (e.g. using show_table), this may cause an error. This can be avoided by always adding any tables last.
- plotly_manager#
- class pybop.plot.backends.PlotlyManager[source]#
Manages the installation and configuration of Plotly for generating visualizations.
This class ensures that Plotly is installed and properly configured to display plots in a web browser.
Upon instantiation, it checks for Plotly’s presence, installs it if missing, and configures the default renderer and browser settings.
- go#
The Plotly graph_objects module for creating figures.
- Type:
module
- pio#
The Plotly input/output module for configuring the renderer.
- Type:
module
- make_subplots#
The function from Plotly for creating subplot figures.
- Type:
function
Examples
>>> plotly_manager = PlotlyManager()
- check_browser_availability()[source]#
Confirm a web browser is available for Plotly’s ‘browser’ renderer; provide guidance if not.
- check_renderer_settings()[source]#
Check and provide information on setting the Plotly renderer if it’s not already set.
- ensure_plotly_installed()[source]#
Check if Plotly is installed and import necessary modules; prompt for installation if missing.
- post_install_setup()[source]#
Import Plotly modules and set the default renderer after installation.
- prompt_for_plotly_installation()[source]#
Prompt the user for Plotly installation and install it upon agreement.
- go = None#
- make_subplots = None#
- pio = None#
- px = None#