@@ -1553,15 +1553,28 @@ 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
1557- result in a 100x100 grid being plotted.
1556+ arrays are passed in, the default values for the strides will
1557+ result in a 100x100 grid being plotted. Defaults to 10.
1558+ Raises a ValueError if both stride and count kwargs
1559+ (see next section) are provided.
1560+
1561+ The `rcount` and `ccount` kwargs supersedes `rstride` and
1562+ `cstride` for default sampling method for surface plotting.
1563+ These arguments will determine at most how many evenly spaced
1564+ samples will be taken from the input data to generate the graph.
1565+ This is the default sampling method unless using the 'classic'
1566+ style. Will raise ValueError if both stride and count are
1567+ specified.
1568+ Added in v2.0.0.
15581569
15591570 ============= ================================================
15601571 Argument Description
15611572 ============= ================================================
15621573 *X*, *Y*, *Z* Data values as 2D arrays
1563- *rstride* Array row stride (step size), defaults to 10
1564- *cstride* Array column stride (step size), defaults to 10
1574+ *rstride* Array row stride (step size)
1575+ *cstride* Array column stride (step size)
1576+ *rcount* Use at most this many rows, defaults to 50
1577+ *ccount* Use at most this many columns, defaults to 50
15651578 *color* Color of the surface patches
15661579 *cmap* A colormap for the surface patches.
15671580 *facecolors* Face colors for the individual patches
@@ -1582,8 +1595,30 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15821595 X , Y , Z = np .broadcast_arrays (X , Y , Z )
15831596 rows , cols = Z .shape
15841597
1598+ has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1599+ has_count = 'rcount' in kwargs or 'ccount' in kwargs
1600+
1601+ if has_stride and has_count :
1602+ raise ValueError ("Cannot specify both stride and count arguments" )
1603+
15851604 rstride = kwargs .pop ('rstride' , 10 )
15861605 cstride = kwargs .pop ('cstride' , 10 )
1606+ rcount = kwargs .pop ('rcount' , 50 )
1607+ ccount = kwargs .pop ('ccount' , 50 )
1608+
1609+ if rcParams ['_internal.classic_mode' ]:
1610+ # Strides have priority over counts in classic mode.
1611+ # So, only compute strides from counts
1612+ # if counts were explicitly given
1613+ if has_count :
1614+ rstride = int (np .ceil (rows / rcount ))
1615+ cstride = int (np .ceil (cols / ccount ))
1616+ else :
1617+ # If the strides are provided then it has priority.
1618+ # Otherwise, compute the strides from the counts.
1619+ if not has_stride :
1620+ rstride = int (np .ceil (rows / rcount ))
1621+ cstride = int (np .ceil (cols / ccount ))
15871622
15881623 if 'facecolors' in kwargs :
15891624 fcolors = kwargs .pop ('facecolors' )
@@ -1733,7 +1768,21 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17331768 The `rstride` and `cstride` kwargs set the stride used to
17341769 sample the input data to generate the graph. If either is 0
17351770 the input data in not sampled along this direction producing a
1736- 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 superseded 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.
17371786
17381787 ========== ================================================
17391788 Argument Description
@@ -1742,6 +1791,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17421791 *Z*
17431792 *rstride* Array row stride (step size), defaults to 1
17441793 *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
17451796 ========== ================================================
17461797
17471798 Keyword arguments are passed on to
@@ -1750,15 +1801,37 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17501801 Returns a :class:`~mpl_toolkits.mplot3d.art3d.Line3DCollection`
17511802 '''
17521803
1753- rstride = kwargs .pop ("rstride" , 1 )
1754- cstride = kwargs .pop ("cstride" , 1 )
1755-
17561804 had_data = self .has_data ()
17571805 Z = np .atleast_2d (Z )
17581806 # FIXME: Support masked arrays
17591807 X , Y , Z = np .broadcast_arrays (X , Y , Z )
17601808 rows , cols = Z .shape
17611809
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+
17621835 # We want two sets of lines, one running along the "rows" of
17631836 # Z and another set of lines running along the "columns" of Z.
17641837 # This transpose will make it easy to obtain the columns.
0 commit comments