pybop.plotting.plot2d#
Functions#
|
Retrieve parameter bounds from a cost object's associated problem parameters. |
|
Plot a 2D visualisation of a cost landscape using Plotly. |
Module Contents#
- pybop.plotting.plot2d.get_param_bounds(cost)[source]#
Retrieve parameter bounds from a cost object’s associated problem parameters.
- Parameters:
cost (object) – The cost object with an associated ‘problem’ attribute containing ‘parameters’.
- Returns:
bounds – An array of shape (n_parameters, 2) containing the bounds for each parameter.
- Return type:
numpy.ndarray
- pybop.plotting.plot2d.plot2d(cost_or_optim, gradient=False, bounds=None, steps=10, show=True, **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 get_param_bounds.
steps (int, optional) – The number of intervals to divide the parameter space into along each dimension (default is 10).
show (bool, optional) – If True, the figure is shown upon creation (default: True).
**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.