8000 Allow passing infinite rcount & ccount to plot_surface, plot_wireframe. · matplotlib/matplotlib@6f5a530 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f5a530

Browse files
committed
Allow passing infinite rcount & ccount to plot_surface, plot_wireframe.
Passing an infinite rcount and ccount is the easiest way to ensure the data does not get downsampled (which I still think is a misfeature, but that's a battle for another day), but would result in a stride of zero; instead, ensure that the stride is at least 1.
1 parent ee768ff commit 6f5a530

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,8 +1570,8 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15701570
15711571
The *rcount* and *ccount* kwargs, which both default to 50,
15721572
determine the maximum number of samples used in each direction. If
1573-
the input data is larger, it will be downsampled to these numbers
1574-
of points.
1573+
the input data is larger, it will be downsampled (by slicing) to
1574+
these numbers of points.
15751575
15761576
Parameters
15771577
----------
@@ -1580,8 +1580,8 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15801580
15811581
rcount, ccount : int
15821582
Maximum number of samples used in each direction. If the input
1583-
data is larger, it will be downsampled to these numbers of points.
1584-
Defaults to 50.
1583+
data is larger, it will be downsampled (by slicing) to these
1584+
numbers of points. Defaults to 50.
15851585
15861586
rstride, cstride : int
15871587
Downsampling stride in each direction. These arguments are
@@ -1637,14 +1637,14 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
16371637
# So, only compute strides from counts
16381638
# if counts were explicitly given
16391639
if has_count:
1640-
rstride = int(np.ceil(rows / rcount))
1641-
cstride = int(np.ceil(cols / ccount))
1640+
rstride = int(max(np.ceil(rows / rcount), 1))
1641+
cstride = int(max(np.ceil(cols / ccount), 1))
16421642
else:
16431643
# If the strides are provided then it has priority.
16441644
# Otherwise, compute the strides from the counts.
16451645
if not has_stride:
1646-
rstride = int(np.ceil(rows / rcount))
1647-
cstride = int(np.ceil(cols / ccount))
1646+
rstride = int(max(np.ceil(rows / rcount), 1))
1647+
cstride = int(max(np.ceil(cols / ccount), 1))
16481648

16491649
if 'facecolors' in kwargs:
16501650
fcolors = kwargs.pop('facecolors')
@@ -1795,8 +1795,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17951795
17961796
The *rcount* and *ccount* kwargs, which both default to 50,
17971797
determine the maximum number of samples used in each direction. If
1798-
the input data is larger, it will be downsampled to these numbers
1799-
of points.
1798+
the input data is larger, it will be downsampled (by slicing) to
1799+
these numbers of points.
18001800
18011801
Parameters
18021802
----------
@@ -1805,10 +1805,10 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
18051805
18061806
rcount, ccount : int
18071807
Maximum number of samples used in each direction. If the input
1808-
data is larger, it will be downsampled to these numbers of points.
1809-
Setting a count to zero causes the data to be not sampled in the
1810-
corresponding direction, producing a 3D line plot rather than a
1811-
wireframe plot. Defaults to 50.
1808+
data is larger, it will be downsampled (by slicing) to these
1809+
numbers of points. Setting a count to zero causes the data to be
1810+
not sampled in the corresponding direction, producing a 3D line
1811+
plot rather than a wireframe plot. Defaults to 50.
18121812
18131813
rstride, cstride : int
18141814
Downsampling stride in each direction. These arguments are
@@ -1848,14 +1848,14 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
18481848
# So, only compute strides from counts
18491849
# if counts were explicitly given
18501850
if has_count:
1851-
rstride = int(np.ceil(rows / rcount)) if rcount else 0
1852-
cstride = int(np.ceil(cols / ccount)) if ccount else 0
1851+
rstride = int(max(np.ceil(rows / rcount), 1)) if rcount else 0
1852+
cstride = int(max(np.ceil(cols / ccount), 1)) if ccount else 0
18531853
else:
18541854
# If the strides are provided then it has priority.
18551855
# Otherwise, compute the strides from the counts.
18561856
if not has_stride:
1857-
rstride = int(np.ceil(rows / rcount)) if rcount else 0
1858-
cstride = int(np.ceil(cols / ccount)) if ccount else 0
1857+
rstride = int(max(np.ceil(rows / rcount), 1)) if rcount else 0
1858+
cstride = int(max(np.ceil(cols / ccount), 1)) if ccount else 0
18591859

18601860
# We want two sets of lines, one running along the "rows" of
18611861
# Z and another set of lines running along the "columns" of Z.

0 commit comments

Comments
 (0)
0