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 66a8722

Browse filesBrowse files
committed
Support only positional args for data in contour
1 parent cc85fb6 commit 66a8722
Copy full SHA for 66a8722

File tree

Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-3
lines changed

‎lib/matplotlib/contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/contour.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ def _process_args(self, *args, corner_mask=None, algorithm=None, **kwargs):
13861386
"""
13871387
Process args and kwargs.
13881388
"""
1389-
if isinstance(args[0], QuadContourSet):
1389+
if args and isinstance(args[0], QuadContourSet):
13901390
if self.levels is None:
13911391
self.levels = args[0].levels
13921392
self.zmin = args[0].zmin
@@ -1446,11 +1446,11 @@ def _contour_args(self, args, kwargs):
14461446
else:
14471447
fn = 'contour'
14481448
nargs = len(args)
1449-
if nargs <= 2:
1449+
if 0 < nargs <= 2:
14501450
z = ma.asarray(args[0], dtype=np.float64)
14511451
x, y = self._initialize_x_y(z)
14521452
args = args[1:]
1453-
elif nargs <= 4:
1453+
elif 2 < nargs <= 4:
14541454
x, y, z = self._check_xyz(args[:3], kwargs)
14551455
args = args[3:]
14561456
else:

‎lib/matplotlib/tests/test_contour.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_contour.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,3 +693,10 @@ def test_contour_remove():
693693
assert ax.get_children() != orig_children
694694
cs.remove()
695695
assert ax.get_children() == orig_children
696+
697+
698+
def test_contour_no_args():
699+
fig, ax = plt.subplots()
700+
data = [[0, 1], [1, 0]]
701+
with pytest.raises(TypeError, match=r"contour\(\) takes from 1 to 4"):
702+
ax.contour(Z=data)

0 commit comments

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