differt.plotting.draw_surface#
- draw_surface(x=None, y=None, *, z, colors=None, **kwargs)[source]#
Plot a 3D surface.
- Parameters:
x (
Real[ArrayLike, 'cols']|Real[ArrayLike, 'rows cols']|None) – The x-coordinates corresponding to first dimension of the surface.y (
Real[ArrayLike, 'rows']|Real[ArrayLike, 'rows cols']|None) – The y-coordinates corresponding to second dimension of the surface.z (
Real[ArrayLike, 'rows cols']) – The z-coordinates corresponding to third dimension of the surface.colors (
Real[ArrayLike, 'rows cols']|Real[ArrayLike, 'rows cols 3']|None) –The color of values to use.
In the Plotly backend, the default is to use the values in
z.kwargs (
Any) – Keyword arguments passed toIsocurve,contour, orSurface, depending on the backend.
- Return type:
- Returns:
The resulting plot output.
Warning
Matplotlib requires
colorsto be RGB or RGBA values. VisPy currently does not support colors.Examples
The following example shows how to plot a 3-D surface, without and with custom coloring.
>>> from differt.plotting import draw_surface >>> >>> u = np.linspace(0, 2 * np.pi, 100) >>> v = np.linspace(0, np.pi, 100) >>> x = np.outer(np.cos(u), np.sin(v)) >>> y = np.outer(np.sin(u), np.sin(v)) >>> z = np.outer(np.cos(u), np.cos(v)) >>> fig1 = draw_surface(x, y, z=z, backend="plotly") >>> fig1 >>> >>> fig2 = draw_surface( ... x, y, z=z, colors=x * x + y * y + z * z, backend="plotly" ... ) >>> fig2