pybop.plotting.plot2d#
Functions#
|
Plot a 2D visualisation of a cost landscape using Plotly. |
Module Contents#
- pybop.plotting.plot2d.plot2d(cost_or_optim, gradient: bool = False, bounds: numpy.ndarray = None, steps: int = 10, show: bool = True, use_optim_log: bool = False, **layout_kwargs)[source]#
Plot a 2D visualisation of a cost landscape using Plotly.
This function generates a contour plot representing the cost landscape for a provided callable cost function over a grid of parameter values within the specified bounds.
- Parameters:
cost_or_optim (a callable cost function, pybop Cost or Optimisation object) – Either: - the cost function to be evaluated. Must accept a list of parameter values and return a cost value. - an Optimisation object which provides a specific optimisation trace overlaid on the cost landscape.
gradient (bool, optional) – If True, the gradient is shown (default: False).
bounds (numpy.ndarray, optional) – A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses cost.parameters.get_bounds_for_plotly.
steps (int, optional) – The number of grid points to divide the parameter space into along each dimension (default: 10).
show (bool, optional) – If True, the figure is shown upon creation (default: True).
use_optim_log (bool, optional) – If True, the optimisation log is used to shape the cost landscape (default: False).
**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 containing the cost landscape plot.
- Return type:
plotly.graph_objs.Figure
- Raises:
ValueError – If the cost function does not return a valid cost when called with a parameter list.