|
| 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, the |
| 10 | +entire segment or patch will be hidden. Not being able to show partial lines |
| 11 | +or patches such that they are "smoothly" cut off at the boundaries of the view |
| 12 | +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, axs = plt.subplots(1, 2, subplot_kw={"projection": "3d"}) |
| 22 | + np.random.seed(1) |
| 23 | + ps = np.random.rand(25, 3) |
| 24 | + |
| 25 | + axs[0].plot(ps[:, 0], ps[:, 1], ps[:, 2], c='k', alpha=0.5) |
| 26 | + axs[0].scatter(ps[:, 0], ps[:, 1], ps[:, 2]) |
| 27 | + axs[0].set(xlim=(0.25, 0.75), ylim=(0, 1), zlim=(0, 1), |
| 28 | + title='axlim_clip=False (default)') |
| 29 | + |
| 30 | + # Note that when a line has one vertex outside the view limits, the entire |
| 31 | + # line is hidden. The same is true for 3D patches (not shown). |
| 32 | + axs[1].plot(ps[:, 0], ps[:, 1], ps[:, 2], c='k', alpha=0.5, axlim_clip=True) |
| 33 | + axs[1].scatter(ps[:, 0], ps[:, 1], ps[:, 2], axlim_clip=True) |
| 34 | + axs[1].set(xlim=(0.25, 0.75), ylim=(0, 1), zlim=(0, 1), |
| 35 | + title='axlim_clip=True') |
0 commit comments