Skip to content

Commit 302c7fd

Browse files
committed
Merge pull request matplotlib#6202 from mdboom/default-scatter-size
Fix matplotlib#6136: Don't hardcode default scatter size
1 parent 4e14ae0 commit 302c7fd

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

doc/users/whats_new/style_changes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ Colors
2828
- Grid lines are light grey solid 1pt lines. They are no longer dashed by
2929
default.
3030

31+
Plots
32+
`````
33+
34+
- The default size of the elements in a scatter plot is now based on
35+
the rcParam ``lines.markersize`` so it is consistent with ``plot(X,
36+
Y, 'o')``. The old value was 20, and the new value is 36 (6^2).
37+
3138
Plot layout
3239
```````````
3340

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,7 +3725,7 @@ def dopatch(xs, ys, **kwargs):
37253725
'facecolors', 'color'],
37263726
label_namer="y")
37273727
@docstring.dedent_interpd
3728-
def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
3728+
def scatter(self, x, y, s=None, c=None, marker='o', cmap=None, norm=None,
37293729
vmin=None, vmax=None, alpha=None, linewidths=None,
37303730
verts=None, edgecolors=None,
37313731
**kwargs):
@@ -3738,8 +3738,8 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
37383738
x, y : array_like, shape (n, )
37393739
Input data
37403740
3741-
s : scalar or array_like, shape (n, ), optional, default: 20
3742-
size in points^2.
3741+
s : scalar or array_like, shape (n, ), optional
3742+
size in points^2. Default is `rcParams['lines.markersize'] ** 2`.
37433743
37443744
c : color, sequence, or sequence of color, optional, default: 'b'
37453745
`c` can be a single color format string, or a sequence of color
@@ -3860,6 +3860,12 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38603860
if x.size != y.size:
38613861
raise ValueError("x and y must be the same size")
38623862

3863+
if s is None:
3864+
if rcParams['_internal.classic_mode']:
3865+
s = 20
3866+
else:
3867+
s = rcParams['lines.markersize'] ** 2.0
3868+
38633869
s = np.ma.ravel(s) # This doesn't have to match x, y in size.
38643870

38653871
# After this block, c_array will be None unless

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ def quiverkey(*args, **kw):
32313231
# This function was autogenerated by boilerplate.py. Do not edit as
32323232
# changes will be lost
32333233
@_autogen_docstring(Axes.scatter)
3234-
def scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None,
3234+
def scatter(x, y, s=None, c=None, marker='o', cmap=None, norm=None, vmin=None,
32353235
vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
32363236
hold=None, data=None, **kwargs):
32373237
ax = gca()

0 commit comments

Comments
 (0)