From ff239cf988529cc286161c14561659edbf653947 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Fri, 16 Dec 2022 14:35:10 +0100 Subject: [PATCH] Support kwargs only calls to contour --- lib/matplotlib/contour.py | 2 +- lib/matplotlib/tests/test_contour.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 144eadeae2c6..b571c1aa5987 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -1386,7 +1386,7 @@ def _process_args(self, *args, corner_mask=None, algorithm=None, **kwargs): """ Process args and kwargs. """ - if isinstance(args[0], QuadContourSet): + if args and isinstance(args[0], QuadContourSet): if self.levels is None: self.levels = args[0].levels self.zmin = args[0].zmin diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index e42206b8cb79..b1058fcbdebc 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -693,3 +693,9 @@ def test_contour_remove(): assert ax.get_children() != orig_children cs.remove() assert ax.get_children() == orig_children + + +def test_countour_kwargsonly(): + # Smoke test for GH#24743 + # Passing only kwargs + plt.contour(Z=np.random.rand(30, 30))