pybop.plot.contour#

Functions#

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

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

Module Contents#

pybop.plot.contour.contour(call_object: Problem | OptimisationResult, gradient: bool = False, bounds: numpy.ndarray | None = None, transformed: bool = False, steps: int = 10, show: bool = 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:
  • call_object (pybop.Problem | pybop.OptimisationResult) – Either: - the cost function to be evaluated. Must accept a list of parameter values and return a cost value. - an optimiser result 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 | list[list[float]], optional) – A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses parameters.get_bounds_for_plotly.

  • transformed (bool, optional) – Uses the transformed parameter values (as seen by the optimiser) for plotting.

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

  • **layout_kwargs (optional) – Valid Plotly layout keys and their values, e.g. xaxis_title=”Time [s]” or xaxis={“title”: “Time [s]”, font={“size”:14}}

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.