Skip to content

Commit f124032

Browse files
committed
Bring r/ccount features to plot_wireframe
1 parent 08e089d commit f124032

File tree

6 files changed

+4957
-4906
lines changed

6 files changed

+4957
-4906
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+44-6
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15531553
15541554
The `rstride` and `cstride` kwargs set the stride used to
15551555
sample the input data to generate the graph. If 1k by 1k
1556-
arrays are passed in the default values for the strides will
1556+
arrays are passed in, the default values for the strides will
15571557
result in a 100x100 grid being plotted. Defaults to 10.
15581558
Raises a ValueError if both stride and count kwargs
15591559
(see next section) are provided.
@@ -1596,7 +1596,7 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15961596
rows, cols = Z.shape
15971597

15981598
has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1599-
has_count = 'rcount' in kwargs or 'rcount' in kwargs
1599+
has_count = 'rcount' in kwargs or 'ccount' in kwargs
16001600

16011601
if has_stride and has_count:
16021602
raise ValueError("Cannot specify both stride and count arguments")
@@ -1768,7 +1768,21 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17681768
The `rstride` and `cstride` kwargs set the stride used to
17691769
sample the input data to generate the graph. If either is 0
17701770
the input data in not sampled along this direction producing a
1771-
3D line plot rather than a wireframe plot.
1771+
3D line plot rather than a wireframe plot. The stride arguments
1772+
are only used by default if in the 'classic' mode. They are
1773+
now superceeded by `rcount` and `ccount`. Will raise ValueError
1774+
if both stride and count are used.
1775+
1776+
` The `rcount` and `ccount` kwargs supersedes `rstride` and
1777+
`cstride`for default sampling method for wireframe plotting.
1778+
These arguments will determine at most how many evenly spaced
1779+
samples will be taken from the input data to generate the graph.
1780+
This is the default sampling method unless using the 'classic'
1781+
style. Will raise ValueError if both stride and count are
1782+
specified. If either is zero, then the input data is not sampled
1783+
along this direction, producing a 3D line plot rather than a
1784+
wireframe plot.
1785+
Added in v2.0.0.
17721786
17731787
========== ================================================
17741788
Argument Description
@@ -1777,6 +1791,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17771791
*Z*
17781792
*rstride* Array row stride (step size), defaults to 1
17791793
*cstride* Array column stride (step size), defaults to 1
1794+
*rcount* Use at most this many rows, defaults to 50
1795+
*ccount* Use at most this many columns, defaults to 50
17801796
========== ================================================
17811797
17821798
Keyword arguments are passed on to
@@ -1785,15 +1801,37 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17851801
Returns a :class:`~mpl_toolkits.mplot3d.art3d.Line3DCollection`
17861802
'''
17871803

1788-
rstride = kwargs.pop("rstride", 1)
1789-
cstride = kwargs.pop("cstride", 1)
1790-
17911804
had_data = self.has_data()
17921805
Z = np.atleast_2d(Z)
17931806
# FIXME: Support masked arrays
17941807
X, Y, Z = np.broadcast_arrays(X, Y, Z)
17951808
rows, cols = Z.shape
17961809

1810+
has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1811+
has_count = 'rcount' in kwargs or 'ccount' in kwargs
1812+
1813+
if has_stride and has_count:
1814+
raise ValueError("Cannot specify both stride and count arguments")
1815+
1816+
rstride = kwargs.pop('rstride', 1)
1817+
cstride = kwargs.pop('cstride', 1)
1818+
rcount = kwargs.pop('rcount', 50)
1819+
ccount = kwargs.pop('ccount', 50)
1820+
1821+
if rcParams['_internal.classic_mode']:
1822+
# Strides have priority over counts in classic mode.
1823+
# So, only compute strides from counts
1824+
# if counts were explicitly given
1825+
if has_count:
1826+
rstride = int(np.ceil(rows / rcount)) if rcount else 0
1827+
cstride = int(np.ceil(cols / ccount)) if ccount else 0
1828+
else:
1829+
# If the strides are provided then it has priority.
1830+
# Otherwise, compute the strides from the counts.
1831+
if not has_stride:
1832+
rstride = int(np.ceil(rows / rcount)) if rcount else 0
1833+
cstride = int(np.ceil(cols / ccount)) if ccount else 0
1834+
17971835
# We want two sets of lines, one running along the "rows" of
17981836
# Z and another set of lines running along the "columns" of Z.
17991837
# This transpose will make it easy to obtain the columns.
Binary file not shown.

0 commit comments

Comments
 (0)