pybop.plot.contour#

Functions#

contour(call_object[, gradient, bounds, ...])

Plot a 2D visualisation of a cost landscape using Plotly.

Module Contents#

pybop.plot.contour.contour(call_object: pybop.BaseCost | pybop.BaseOptimiser, gradient: bool = False, bounds: numpy.ndarray | None = None, apply_transform: bool = False, 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:
  • call_object (Union([pybop.BaseCost,pybop.BaseOptimiser, pybop.BasePrior])) – 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.

  • apply_transform (bool, optional) – Converts contour landscape into transformed landscape that was used by the optimiser.

  • 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.