Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c61074d

Browse files
committed
scatter() should not rescale if norm is given
1 parent 24caa1b commit c61074d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4471,10 +4471,11 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44714471
collection.set_cmap(cmap)
44724472
collection.set_norm(norm)
44734473

4474-
if vmin is not None or vmax is not None:
4475-
collection.set_clim(vmin, vmax)
4476-
else:
4477-
collection.autoscale_None()
4474+
if norm is None:
4475+
if vmin is not None or vmax is not None:
4476+
collection.set_clim(vmin, vmax)
4477+
else:
4478+
collection.autoscale_None()
44784479

44794480
# Classic mode only:
44804481
# ensure there are margins to allow for the

lib/matplotlib/tests/test_axes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1973,6 +1973,14 @@ def test_scatter_no_invalid_color(self, fig_test, fig_ref):
19731973
ax = fig_ref.subplots()
19741974
ax.scatter([0, 2], [0, 2], c=[1, 2], s=[1, 3], cmap=cmap)
19751975

1976+
@check_figures_equal(extensions=["png"])
1977+
def test_scatter_norm_vminvmax(self, fig_test, fig_ref):
1978+
x = [1, 2, 3]
1979+
ax = fig_ref.subplots()
1980+
ax.scatter(x, x, c=x, norm=mcolors.Normalize(-10, 10))
1981+
ax = fig_test.subplots()
1982+
ax.scatter(x, x, c=x, norm=mcolors.Normalize(-10, 10), vmin=0, vmax=5)
1983+
19761984
@check_figures_equal(extensions=["png"])
19771985
def test_scatter_single_point(self, fig_test, fig_ref):
19781986
ax = fig_test.subplots()

0 commit comments

Comments
 (0)