|
| 1 | +Data in 3D plots can now be dynamically clipped to the axes view limits |
| 2 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3 | + |
| 4 | +All 3D plotting functions now support the *axlim_clip* keyword argument, which |
| 5 | +will clip the data to the axes view limits, hiding all data outside those |
| 6 | +bounds. This clipping will be dynamically applied in real time while panning |
| 7 | +and zooming. |
| 8 | + |
| 9 | +Please note that if one vertex of a line segment or 3D patch is clipped, then |
| 10 | +the entire segment or patch will be hidden. Not being able to show partial |
| 11 | +lines or patches such that they are "smoothly" cut off at the boundaries of the |
| 12 | +view box is a limitation of the current renderer. |
| 13 | + |
| 14 | +.. plot:: |
| 15 | + :include-source: true |
| 16 | + :alt: Example of default behavior (left) and axlim_clip=True (right) |
| 17 | + |
| 18 | + import matplotlib.pyplot as plt |
| 19 | + import numpy as np |
| 20 | + |
| 21 | + fig, ax = plt.subplots(subplot_kw={"projection": "3d"}) |
| 22 | + np.random.seed(1) |
| 23 | + xyz = np.random.rand(25, 3) |
| 24 | + |
| 25 | + # Note that when a line has one vertex outside the view limits, the entire |
| 26 | + # line is hidden. The same is true for 3D patches (not shown). |
| 27 | + ax.plot(xyz[:, 0], xyz[:, 1], xyz[:, 2], '-o') |
| 28 | + ax.plot(xyz[:, 0], xyz[:, 1], xyz[:, 2], '--*', axlim_clip=True) |
| 29 | + ax.set(xlim=(0.25, 0.75), ylim=(0, 1), zlim=(0, 1)) |
| 30 | + ax.legend(['axlim_clip=False (default)', 'axlim_clip=True']) |
0 commit comments