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 | Result, gradient: bool = False, bounds: numpy.ndarray | None = None, transformed: bool = False, steps: int = 10, title='Cost Landscape', show: bool = True, backend: str | pybop.plot.backends.PlotBackend = None, figures=None, axes=None)[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.Result) – 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.

  • title (str, optional) – The title of the figure (default: “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).

  • backend (str or pybop.plot.backends.PlotBackend, optional) – The plotting backend to be used.

  • figures (figure object or list of figure objects, optional) – Either a single figure or the same number of figures as axes.

  • axes (single axis or list of axes, optional) – plotly: axes expected to be of the form tuple(row, col) If gradient is false this must be a single axis. If gradient is true this must be one axis for the cost contour plot and one axis for each parameter to plot the gradient.

Returns:

  • None (if show is True)

  • figure object containing the cost landscape (if show is False and gradient is False)

  • tuple (fig, grad_figs) (if show is False and gradient is True) – fig - figure object containing the cost landscape grad_figs - list of figure objects containing the gradient for each parameter

Raises:

ValueError – If the cost function does not return a valid cost when called with a parameter list.