@@ -1553,15 +1553,28 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
1553
1553
1554
1554
The `rstride` and `cstride` kwargs set the stride used to
1555
1555
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.
1558
1569
1559
1570
============= ================================================
1560
1571
Argument Description
1561
1572
============= ================================================
1562
1573
*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
1565
1578
*color* Color of the surface patches
1566
1579
*cmap* A colormap for the surface patches.
1567
1580
*facecolors* Face colors for the individual patches
@@ -1582,8 +1595,30 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
1582
1595
X , Y , Z = np .broadcast_arrays (X , Y , Z )
1583
1596
rows , cols = Z .shape
1584
1597
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
+
1585
1604
rstride = kwargs .pop ('rstride' , 10 )
1586
1605
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 ))
1587
1622
1588
1623
if 'facecolors' in kwargs :
1589
1624
fcolors = kwargs .pop ('facecolors' )
@@ -1733,7 +1768,21 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
1733
1768
The `rstride` and `cstride` kwargs set the stride used to
1734
1769
sample the input data to generate the graph. If either is 0
1735
1770
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.
1737
1786
1738
1787
========== ================================================
1739
1788
Argument Description
@@ -1742,6 +1791,8 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
1742
1791
*Z*
1743
1792
*rstride* Array row stride (step size), defaults to 1
1744
1793
*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
1745
1796
========== ================================================
1746
1797
1747
1798
Keyword arguments are passed on to
@@ -1750,15 +1801,37 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
1750
1801
Returns a :class:`~mpl_toolkits.mplot3d.art3d.Line3DCollection`
1751
1802
'''
1752
1803
1753
- rstride = kwargs .pop ("rstride" , 1 )
1754
- cstride = kwargs .pop ("cstride" , 1 )
1755
-
1756
1804
had_data = self .has_data ()
1757
1805
Z = np .atleast_2d (Z )
1758
1806
# FIXME: Support masked arrays
1759
1807
X , Y , Z = np .broadcast_arrays (X , Y , Z )
1760
1808
rows , cols = Z .shape
1761
1809
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
+
1762
1835
# We want two sets of lines, one running along the "rows" of
1763
1836
# Z and another set of lines running along the "columns" of Z.
1764
1837
# This transpose will make it easy to obtain the columns.
0 commit comments