differt.plotting.draw_contour#
- draw_contour(data, x=None, y=None, z0=0.0, levels=None, fill=False, **kwargs)[source]#
Plot a 2D contour on a 3D canvas, at a fixed z-coordinate.
- Parameters:
data (
Real[ArrayLike, 'rows cols']) – The values over which the contour is drawn.x (
Real[ArrayLike, 'cols']|Real[ArrayLike, 'rows cols 3']|None) – The x-coordinates corresponding to first dimension of the contour. Those coordinates will be used to scale and translate the contour.y (
Real[ArrayLike, 'rows']|Real[ArrayLike, 'rows cols 3']|None) – The y-coordinates corresponding to second dimension of the contour. Those coordinates will be used to scale and translate the contour.z0 (
float) – The z-coordinate at which the contour is placed.levels (
int|Real[ArrayLike, 'num_levels']|None) – The levels at which the contour is drawn.fill (
bool) – Whether to fill the contour.kwargs (
Any) – Keyword arguments passed toIsocurve,contour, (orcontourfiffillisTrue), orContour, depending on the backend.
- Return type:
- Returns:
The resulting plot output.
Warning
VisPy does not support filling the contour. Plotly does not support 3D contours, and will draw the contour on a 2D figure instead.
Examples
The following example shows how to plot a 2-D contour, without and with axis scaling, and filling.
>>> from differt.plotting import draw_contour >>> >>> x = np.linspace(-1.0, +1.0, 10) >>> y = np.linspace(-4.0, +4.0, 20) >>> X, Y = np.meshgrid(x, y) >>> Z = np.cos(X) * np.sin(Y) >>> fig1 = draw_contour(Z, backend="plotly") >>> fig1 >>> >>> fig2 = draw_contour(Z, x=x, y=y, fill=True, backend="plotly") >>> fig2