differt.plotting.draw_image

Contents

differt.plotting.draw_image#

draw_image(data, x=None, y=None, z0=0.0, **kwargs)[source]#

Plot a 2D image on a 3D canvas, at a fixed z-coordinate.

Parameters:
Return type:

Any

Returns:

The resulting plot output.

Warning

Matplotlib backend requires data to be either an RGB or an RGBA array.

Examples

The following example shows how to plot a 2-D image, without and with axis scaling.

>>> from differt.plotting import draw_image
>>>
>>> x = np.linspace(-1.0, +1.0, 100)
>>> y = np.linspace(-4.0, +4.0, 200)
>>> X, Y = np.meshgrid(x, y)
>>> Z = np.sin(X) * np.cos(Y)
>>> # Let's mask some values to draw a ring
>>> R = np.sqrt(16 * X * X + Y * Y)
>>> Z = np.where((R > 0.5) & (R < 1.5), np.nan, Z)
>>> fig1 = draw_image(Z, backend="plotly")
>>> fig1
>>>
>>> fig2 = draw_image(Z, x=x, y=y, backend="plotly")
>>> fig2