diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 91badadf088e..d372bde96594 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -4429,13 +4429,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, alpha=alpha ) collection.set_transform(mtransforms.IdentityTransform()) - collection.update(kwargs) - if colors is None: collection.set_array(c) collection.set_cmap(cmap) collection.set_norm(norm) collection._scale_norm(norm, vmin, vmax) + collection.update(kwargs) # Classic mode only: # ensure there are margins to allow for the diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 27fc6aba2e3f..6a6e9a86de18 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1,6 +1,7 @@ from collections import namedtuple import datetime from decimal import Decimal +from functools import partial import io from itertools import product import platform @@ -7271,7 +7272,13 @@ def test_empty_line_plots(): def test_clim(): ax = plt.figure().add_subplot() - for plot_method in [ax.imshow, ax.pcolor, ax.pcolormesh, ax.pcolorfast]: + for plot_method in [ + partial(ax.scatter, range(3), range(3), c=range(3)), + partial(ax.imshow, [[0, 1], [2, 3]]), + partial(ax.pcolor, [[0, 1], [2, 3]]), + partial(ax.pcolormesh, [[0, 1], [2, 3]]), + partial(ax.pcolorfast, [[0, 1], [2, 3]]), + ]: clim = (7, 8) - norm = plot_method([[0, 1], [2, 3]], clim=clim).norm + norm = plot_method(clim=clim).norm assert (norm.vmin, norm.vmax) == clim