Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2f75b39

Browse filesBrowse files
committed
Simplify argument count/stride argument handling for plot_surface()
1 parent e99f590 commit 2f75b39
Copy full SHA for 2f75b39

File tree

Expand file treeCollapse file tree

1 file changed

+22
-18
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-18
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+22-18Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,13 +1555,17 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15551555
sample the input data to generate the graph. If 1k by 1k
15561556
arrays are passed in the default values for the strides will
15571557
result in a 100x100 grid being plotted. Defaults to 10.
1558-
Superceded by `rcount` and `ccount` if both the
1559-
stride and the count are specified as of v2.0.0.
1560-
1561-
The `rcount` and `ccount` kwargs are the new method for
1562-
sampling the input data to generate the graph, and
1563-
supercedes `rstride` and `cstride` (unless using the
1564-
'classic' style) if both are specified. Added in v2.0.0.
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.
15651569
15661570
============= ================================================
15671571
Argument Description
@@ -1591,10 +1595,11 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
15911595
X, Y, Z = np.broadcast_arrays(X, Y, Z)
15921596
rows, cols = Z.shape
15931597

1594-
has_rstride = 'rstride' in kwargs
1595-
has_cstride = 'cstride' in kwargs
1596-
has_rcount = 'rcount' in kwargs
1597-
has_ccount = 'ccount' in kwargs
1598+
has_stride = 'rstride' in kwargs or 'cstride' in kwargs
1599+
has_count = 'rcount' in kwargs or 'rcount' in kwargs
1600+
1601+
if has_stride and has_count:
1602+
raise ValueError("Cannot specify both stride and count arguments")
15981603

15991604
rstride = kwargs.pop('rstride', 10)
16001605
cstride = kwargs.pop('cstride', 10)
@@ -1603,17 +1608,16 @@ def plot_surface(self, X, Y, Z, *args, **kwargs):
16031608

16041609
if rcParams['_internal.classic_mode']:
16051610
# Strides have priority over counts in classic mode.
1606-
if not has_rstride and has_rcount:
1611+
# So, only compute strides from counts
1612+
# if counts were explicitly given
1613+
if has_count:
16071614
rstride = int(np.ceil(rows / rcount))
1608-
if not has_cstride and has_ccount:
16091615
cstride = int(np.ceil(cols / ccount))
16101616
else:
1611-
# If the count is provided then it has priority
1612-
# If neither count or stride is provided then use
1613-
# the default count.
1614-
if has_rcount or (not has_rstride and not has_rcount):
1617+
# If the strides are provided then it has priority.
1618+
# Otherwise, compute the strides from the counts.
1619+
if not has_stride:
16151620
rstride = int(np.ceil(rows / rcount))
1616-
if has_ccount or (not has_cstride and not has_ccount):
16171621
cstride = int(np.ceil(cols / ccount))
16181622

16191623
if 'facecolors' in kwargs:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.