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

Method test_xyz

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py:1515–1545  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1513 @mpl3d_image_comparison(['voxels-xyz.png'], remove_text=False, style='mpl20',
1514 tol=0.002 if sys.platform == 'win32' else 0)
1515 def test_xyz(self):
1516 fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
1517
1518 def midpoints(x):
1519 sl = ()
1520 for i in range(x.ndim):
1521 x = (x[sl + np.index_exp[:-1]] +
1522 x[sl + np.index_exp[1:]]) / 2.0
1523 sl += np.index_exp[:]
1524 return x
1525
1526 # prepare some coordinates, and attach rgb values to each
1527 r, g, b = np.indices((17, 17, 17)) / 16.0
1528 rc = midpoints(r)
1529 gc = midpoints(g)
1530 bc = midpoints(b)
1531
1532 # define a sphere about [0.5, 0.5, 0.5]
1533 sphere = (rc - 0.5)**2 + (gc - 0.5)**2 + (bc - 0.5)**2 < 0.5**2
1534
1535 # combine the color components
1536 colors = np.zeros(sphere.shape + (3,))
1537 colors[..., 0] = rc
1538 colors[..., 1] = gc
1539 colors[..., 2] = bc
1540
1541 # and plot everything
1542 ax.voxels(r, g, b, sphere,
1543 facecolors=colors,
1544 edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighter
1545 linewidth=0.5)
1546
1547 def test_calling_conventions(self):
1548 x, y, z = np.indices((3, 4, 5))

Callers

nothing calls this directly

Calls 4

voxelsMethod · 0.80
midpointsFunction · 0.50
subplotsMethod · 0.45
clipMethod · 0.45

Tested by

no test coverage detected