diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index 8c5c9b566441..ffe680eaef16 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -602,7 +602,7 @@ def __init__(self, ax, *args, hatches=(None,), alpha=None, origin=None, extent=None, cmap=None, colors=None, norm=None, vmin=None, vmax=None, colorizer=None, extend='neither', antialiased=None, nchunk=0, - locator=None, transform=None, negative_linestyles=None, clip_path=None, + locator=None, transform=None, negative_linestyles=None, **kwargs): """ Draw contour lines or filled regions, depending on @@ -656,7 +656,6 @@ def __init__(self, ax, *args, super().__init__( antialiaseds=antialiased, alpha=alpha, - clip_path=clip_path, transform=transform, colorizer=colorizer, ) @@ -672,6 +671,9 @@ def __init__(self, ax, *args, self.nchunk = nchunk self.locator = locator + if "color" in kwargs: + raise _api.kwarg_error("ContourSet.__init__", "color") + if colorizer: self._set_colorizer_check_keywords(colorizer, cmap=cmap, norm=norm, vmin=vmin, @@ -764,23 +766,18 @@ def __init__(self, ax, *args, _api.warn_external('linewidths is ignored by contourf') # Lower and upper contour levels. lowers, uppers = self._get_lowers_and_uppers() - self.set( - edgecolor="none", - # Default zorder taken from Collection - zorder=kwargs.pop("zorder", 1), - rasterized=kwargs.pop("rasterized", False), - ) - + self.set(edgecolor="none") else: self.set( facecolor="none", linewidths=self._process_linewidths(linewidths), linestyle=self._process_linestyles(linestyles), + label="_nolegend_", # Default zorder taken from LineCollection, which is higher # than for filled contours so that lines are displayed on top. - zorder=kwargs.pop("zorder", 2), - label="_nolegend_", + zorder=2, ) + self.set(**kwargs) # Let user-set values override defaults. self.axes.add_collection(self, autolim=False) self.sticky_edges.x[:] = [self._mins[0], self._maxs[0]] @@ -790,12 +787,6 @@ def __init__(self, ax, *args, self.changed() # set the colors - if kwargs: - _api.warn_external( - 'The following kwargs were not used by contour: ' + - ", ".join(map(repr, kwargs)) - ) - allsegs = property(lambda self: [ [subp.vertices for subp in p._iter_connected_components()] for p in self.get_paths()]) diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index c001fc0a9191..89c1c0a6cc96 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -865,3 +865,15 @@ def test_contourf_rasterize(): circle = mpatches.Circle([0.5, 0.5], 0.5, transform=ax.transAxes) cs = ax.contourf(data, clip_path=circle, rasterized=True) assert cs._rasterized + + +@check_figures_equal(extensions=["png"]) +def test_contour_aliases(fig_test, fig_ref): + data = np.arange(100).reshape((10, 10)) ** 2 + fig_test.add_subplot().contour(data, linestyle=":") + fig_ref.add_subplot().contour(data, linestyles="dotted") + + +def test_contour_singular_color(): + with pytest.raises(TypeError): + plt.figure().add_subplot().contour([[0, 1], [2, 3]], color="r") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy