MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / imshow3d

Function imshow3d

galleries/examples/mplot3d/imshow3d.py:31–72  ·  view source on GitHub ↗

Display a 2D array as a color-coded 2D image embedded in 3d. The image will be in a plane perpendicular to the coordinate axis *value_direction*. Parameters ---------- ax : Axes3D The 3D Axes to plot into. array : 2D numpy array The image values. value

(ax, array, value_direction='z', pos=0, norm=None, cmap=None)

Source from the content-addressed store, hash-verified

29
30
31def imshow3d(ax, array, value_direction='z', pos=0, norm=None, cmap=None):
32 """
33 Display a 2D array as a color-coded 2D image embedded in 3d.
34
35 The image will be in a plane perpendicular to the coordinate axis *value_direction*.
36
37 Parameters
38 ----------
39 ax : Axes3D
40 The 3D Axes to plot into.
41 array : 2D numpy array
42 The image values.
43 value_direction : {'x', 'y', 'z'}
44 The axis normal to the image plane.
45 pos : float
46 The numeric value on the *value_direction* axis at which the image plane is
47 located.
48 norm : `~matplotlib.colors.Normalize`, default: Normalize
49 The normalization method used to scale scalar data. See `imshow()`.
50 cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
51 The Colormap instance or registered colormap name used to map scalar data
52 to colors.
53 """
54 if norm is None:
55 norm = Normalize()
56 colors = plt.get_cmap(cmap)(norm(array))
57
58 if value_direction == 'x':
59 nz, ny = array.shape
60 zi, yi = np.mgrid[0:nz + 1, 0:ny + 1]
61 xi = np.full_like(yi, pos)
62 elif value_direction == 'y':
63 nx, nz = array.shape
64 xi, zi = np.mgrid[0:nx + 1, 0:nz + 1]
65 yi = np.full_like(zi, pos)
66 elif value_direction == 'z':
67 ny, nx = array.shape
68 yi, xi = np.mgrid[0:ny + 1, 0:nx + 1]
69 zi = np.full_like(xi, pos)
70 else:
71 raise ValueError(f"Invalid value_direction: {value_direction!r}")
72 ax.plot_surface(xi, yi, zi, rstride=1, cstride=1, facecolors=colors, shade=False)
73
74
75fig = plt.figure()

Callers 1

imshow3d.pyFile · 0.85

Calls 4

NormalizeClass · 0.90
normFunction · 0.85
plot_surfaceMethod · 0.80
get_cmapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…