8000 Code review comments on 3D axlim clipping · matplotlib/matplotlib@7506e37 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7506e37

Browse files
Code review comments on 3D axlim clipping
1 parent 9cb133f commit 7506e37

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def _prepare_points(self):
339339
# This might have changed an ndarray into a masked array.
340340
offset_trf = offset_trf.get_affine()
341341

342-
if np.ma.isMaskedArray(offsets):
342+
if isinstance(offsets, np.ma.MaskedArray):
343343
offsets = offsets.filled(np.nan)
344344
# Changing from a masked array to nan-filled ndarray
345345
# is probably most efficient at this point.

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,11 @@ def do_3d_projection(self):
452452
"""
453453
segments = self._segments3d
454454
if self._axlim_clip:
455-
segments = [np.ma.column_stack([*_viewlim_mask(*zip(*points), self.axes)])
456-
for points in segments]
455+
all_points = np.ma.vstack(segments)
456+
masked_points = np.ma.column_stack([*_viewlim_mask(*all_points.T,
457+
self.axes)])
458+
segment_lengths = [segment.shape[0] for segment in segments]
459+
segments = np.split(masked_points, np.cumsum(segment_lengths[:-1]))
457460
xyslist = [proj3d._proj_trans_points(points, self.axes.M)
458461
for points in segments]
459462
segments_2d = [np.ma.column_stack([xs, ys]) for xs, ys, zs in xyslist]

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,10 +2593,10 @@ def contour(self, X, Y, Z, *args,
25932593
offset : float, optional
25942594
If specified, plot a projection of the contour lines at this
25952595
position in a plane normal to *zdir*.
2596-
data : indexable object, optional
2597-
DATA_PARAMETER_PLACEHOLDER
25982596
axlim_clip : bool, default: False
25992597
Whether to hide lines with a vertex outside the axes view limits.
2598+
data : indexable object, optional
2599+
DATA_PARAMETER_PLACEHOLDER
26002600
26012601
*args, **kwargs
26022602
Other arguments are forwarded to `matplotlib.axes.Axes.contour`.
@@ -2640,10 +2640,10 @@ def tricontour(self, *args,
26402640
offset : float, optional
26412641
If specified, plot a projection of the contour lines at this
26422642
position in a plane normal to *zdir*.
2643-
data : indexable object, optional
2644-
DATA_PARAMETER_PLACEHOLDER
26452643
axlim_clip : bool, default: False
26462644
Whether to hide lines with a vertex outside the axes view limits.
2645+
data : indexable object, optional
2646+
DATA_PARAMETER_PLACEHOLDER
26472647
*args, **kwargs
26482648
Other arguments are forwarded to `matplotlib.axes.Axes.tricontour`.
26492649
@@ -2697,10 +2697,10 @@ def contourf(self, X, Y, Z, *args,
26972697
offset : float, optional
26982698
If specified, plot a projection of the contour lines at this
26992699
position in a plane normal to *zdir*.
2700-
data : indexable object, optional
2701-
DATA_PARAMETER_PLACEHOLDER
27022700
axlim_clip : bool, default: False
27032701
Whether to hide lines with a vertex outside the axes view limits.
2702+
data : indexable object, optional
2703+
DATA_PARAMETER_PLACEHOLDER
27042704
*args, **kwargs
27052705
Other arguments are forwarded to `matplotlib.axes.Axes.contourf`.
27062706
@@ -2737,10 +2737,10 @@ def tricontourf(self, *args, zdir='z', offset=None, axlim_clip=False, **kwargs):
27372737
offset : float, optional
27382738
If specified, plot a projection of the contour lines at this
27392739
position in a plane normal to zdir.
2740-
data : indexable object, optional
2741-
DATA_PARAMETER_PLACEHOLDER
27422740
axlim_clip : bool, default: False
27432741
Whether to hide lines with a vertex outside the axes view limits.
2742+
data : indexable object, optional
2743+
DATA_PARAMETER_PLACEHOLDER
27442744
*args, **kwargs
27452745
Other arguments are forwarded to
27462746
`matplotlib.axes.Axes.tricontourf`.
@@ -2935,10 +2935,10 @@ def bar(self, left, height, zs=0, zdir='z', *args,
29352935
used for all bars.
29362936
zdir : {'x', 'y', 'z'}, default: 'z'
29372937
When plotting 2D data, the direction to use as z ('x', 'y' or 'z').
2938-
data : indexable object, optional
2939-
DATA_PARAMETER_PLACEHOLDER
29402938
axlim_clip : bool, default: False
29412939
Whether to hide bars with points outside the axes view limits.
2940+
data : indexable object, optional
2941+
DATA_PARAMETER_PLACEHOLDER
29422942
**kwargs
29432943
Other keyword arguments are forwarded to
29442944
`matplotlib.axes.Axes.bar`.
@@ -3026,12 +3026,12 @@ def bar3d(self, x, y, z, dx, dy, dz, color=None,
30263026
lightsource : `~matplotlib.colors.LightSource`, optional
30273027
The lightsource to use when *shade* is True.
30283028
3029-
data : indexable object, optional
3030-
DATA_PARAMETER_PLACEHOLDER
3031-
30323029
axlim_clip : bool, default: False
30333030
Whether to hide the bars with points outside the axes view limits.
30343031
3032+
data : indexable object, optional
3033+
DATA_PARAMETER_PLACEHOLDER
3034+
30353035
**kwargs
30363036
Any additional keyword arguments are passed onto
30373037
`~.art3d.Poly3DCollection`.
@@ -3184,12 +3184,12 @@ def quiver(self, X, Y, Z, U, V, W, *,
31843184
Whether all arrows are normalized to have the same length, or keep
31853185
the lengths defined by *u*, *v*, and *w*.
31863186
3187-
data : indexable object, optional
3188-
DATA_PARAMETER_PLACEHOLDER
3189-
31903187
axlim_clip : bool, default: False
31913188
Whether to hide arrows with points outside the axes view limits.
31923189
3190+
data : indexable object, optional
3191+
DATA_PARAMETER_PLACEHOLDER
3192+
31933193
**kwargs
31943194
Any additional keyword arguments are delegated to
31953195
:class:`.Line3DCollection`
@@ -3890,12 +3890,12 @@ def stem(self, x, y, z, *, linefmt='C0-', markerfmt='C0o', basefmt='C3-',
38903890
orientation : {'x', 'y', 'z'}, default: 'z'
38913891
The direction along which stems are drawn.
38923892
3893-
data : indexable object, optional
3894-
DATA_PARAMETER_PLACEHOLDER
3895-
38963893
axlim_clip : bool, default: False
38973894
Whether to hide stems that are outside the axes limits.
38983895
3896+
data : indexable object, optional
3897+
DATA_PARAMETER_PLACEHOLDER
3898+
38993899
Returns
39003900
-------
39013901
`.StemContainer`

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,10 +2177,10 @@ def test_computed_zorder():
21772177
ax.add_collection3d(tri)
21782178

21792179
# plot a vector
2180-
ax.plot((2, 2), (2, 2), (0, 4), c='red', zorder=2, axlim_clip=False)
2180+
ax.plot((2, 2), (2, 2), (0, 4), c='red', zorder=2)
21812181

21822182
# plot some points
2183-
ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10, axlim_clip=False)
2183+
ax.scatter((3, 3), (1, 3), (1, 3), c='red', zorder=10)
21842184

21852185
ax.set_xlim((0, 5.0))
21862186
ax.set_ylim((0, 5.0))

0 commit comments

Comments
 (0)
0