@@ -1557,15 +1557,28 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15571557
15581558 The `rstride` and `cstride` kwargs set the stride used to
15591559 sample the input data to generate the graph. If 1k by 1k
1560- arrays are passed in the default values for the strides will
1561- result in a 100x100 grid being plotted.
1560+ arrays are passed in, the default values for the strides will
1561+ result in a 100x100 grid being plotted. Defaults to 10.
1562+ Raises a ValueError if both stride and count kwargs
1563+ (see next section) are provided.
1564+
1565+ The `rcount` and `ccount` kwargs supersedes `rstride` and
1566+ `cstride` for default sampling method for surface plotting.
1567+ These arguments will determine at most how many evenly spaced
1568+ samples will be taken from the input data to generate the graph.
1569+ This is the default sampling method unless using the 'classic'
1570+ style. Will raise ValueError if both stride and count are
1571+ specified.
1572+ Added in v2.0.0.
15621573
15631574 ============= ================================================
15641575 Argument Description
15651576 ============= ================================================
15661577 *X*, *Y*, *Z* Data values as 2D arrays
1567- *rstride* Array row stride (step size), defaults to 10
1568- *cstride* Array column stride (step size), defaults to 10
1578+ *rstride* Array row stride (step size)
1579+ *cstride* Array column stride (step size)
1580+ *rcount* Use at most this many rows, defaults to 50
1581+ *ccount* Use at most this many columns, defaults to 50
15691582 *color* Color of the surface patches
15701583 *cmap* A colormap for the surface patches.
15711584 *facecolors* Face colors for the individual patches
@@ -1587,8 +1600,30 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15871600 X , Y , Z = np .broadcast_arrays (X , Y , Z )
15881601 rows , cols = Z .shape
15891602
1603+ has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1604+ has_count = 'rcount' in kwargs or 'ccount' in kwargs
1605+
1606+ if has_stride and has_count :
1607+ raise ValueError ("Cannot specify both stride and count arguments" )
1608+
15901609 rstride = kwargs .pop ('rstride' , 10 )
15911610 cstride = kwargs .pop ('cstride' , 10 )
1611+ rcount = kwargs .pop ('rcount' , 50 )
1612+ ccount = kwargs .pop ('ccount' , 50 )
1613+
1614+ if rcParams ['_internal.classic_mode' ]:
1615+ # Strides have priority over counts in classic mode.
1616+ # So, only compute strides from counts
1617+ # if counts were explicitly given
1618+ if has_count :
1619+ rstride = int (np .ceil (rows / rcount ))
1620+ cstride = int (np .ceil (cols / ccount ))
1621+ else :
1622+ # If the strides are provided then it has priority.
1623+ # Otherwise, compute the strides from the counts.
1624+ if not has_stride :
1625+ rstride = int (np .ceil (rows / rcount ))
1626+ cstride = int (np .ceil (cols / ccount ))
15921627
15931628 if 'facecolors' in kwargs :
15941629 fcolors = kwargs .pop ('facecolors' )
@@ -1738,7 +1773,21 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17381773 The `rstride` and `cstride` kwargs set the stride used to
17391774 sample the input data to generate the graph. If either is 0
17401775 the input data in not sampled along this direction producing a
1741- 3D line plot rather than a wireframe plot.
1776+ 3D line plot rather than a wireframe plot. The stride arguments
1777+ are only used by default if in the 'classic' mode. They are
1778+ now superseded by `rcount` and `ccount`. Will raise ValueError
1779+ if both stride and count are used.
1780+
1781+ ` The `rcount` and `ccount` kwargs supersedes `rstride` and
1782+ `cstride` for default sampling method for wireframe plotting.
1783+ These arguments will determine at most how many evenly spaced
1784+ samples will be taken from the input data to generate the graph.
1785+ This is the default sampling method unless using the 'classic'
1786+ style. Will raise ValueError if both stride and count are
1787+ specified. If either is zero, then the input data is not sampled
1788+ along this direction, producing a 3D line plot rather than a
1789+ wireframe plot.
1790+ Added in v2.0.0.
17421791
17431792 ========== ================================================
17441793 Argument Description
@@ -1747,6 +1796,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17471796 *Z*
17481797 *rstride* Array row stride (step size), defaults to 1
17491798 *cstride* Array column stride (step size), defaults to 1
1799+ *rcount* Use at most this many rows, defaults to 50
1800+ *ccount* Use at most this many columns, defaults to 50
17501801 ========== ================================================
17511802
17521803 Keyword arguments are passed on to
@@ -1755,16 +1806,38 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17551806 Returns a :class:`~mpl_toolkits.mplot3d.art3d.Line3DCollection`
17561807 '''
17571808
1758- rstride = kwargs .pop ("rstride" , 1 )
1759- cstride = kwargs .pop ("cstride" , 1 )
1760-
17611809 had_data = self .has_data ()
17621810 if Z .ndim != 2 :
17631811 raise ValueError ("Argument Z must be 2-dimensional." )
17641812 # FIXME: Support masked arrays
17651813 X , Y , Z = np .broadcast_arrays (X , Y , Z )
17661814 rows , cols = Z .shape
17671815
1816+ has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1817+ has_count = 'rcount' in kwargs or 'ccount' in kwargs
1818+
1819+ if has_stride and has_count :
1820+ raise ValueError ("Cannot specify both stride and count arguments" )
1821+
1822+ rstride = kwargs .pop ('rstride' , 1 )
1823+ cstride = kwargs .pop ('cstride' , 1 )
1824+ rcount = kwargs .pop ('rcount' , 50 )
1825+ ccount = kwargs .pop ('ccount' , 50 )
1826+
1827+ if rcParams ['_internal.classic_mode' ]:
1828+ # Strides have priority over counts in classic mode.
1829+ # So, only compute strides from counts
1830+ # if counts were explicitly given
1831+ if has_count :
1832+ rstride = int (np .ceil (rows / rcount )) if rcount else 0
1833+ cstride = int (np .ceil (cols / ccount )) if ccount else 0
1834+ else :
1835+ # If the strides are provided then it has priority.
1836+ # Otherwise, compute the strides from the counts.
1837+ if not has_stride :
1838+ rstride = int (np .ceil (rows / rcount )) if rcount else 0
1839+ cstride = int (np .ceil (cols / ccount )) if ccount else 0
1840+
17681841 # We want two sets of lines, one running along the "rows" of
17691842 # Z and another set of lines running along the "columns" of Z.
17701843 # This transpose will make it easy to obtain the columns.
0 commit comments