Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5487ecd

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 5487ecd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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')
@@ -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)