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

Skip to content

Commit fa18cd4

Browse files
committed
Merge pull request #6202 from mdboom/default-scatter-size
Fix #6136: Don't hardcode default scatter size
2 parents c1aecd1 + 5743e71 commit fa18cd4

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
@@ -3726,7 +3726,7 @@ def dopatch(xs, ys, **kwargs):
37263726
'facecolors', 'color'],
37273727
label_namer="y")
37283728
@docstring.dedent_interpd
3729-
def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
3729+
def scatter(self, x, y, s=None, c=None, marker='o', cmap=None, norm=None,
37303730
vmin=None, vmax=None, alpha=None, linewidths=None,
37313731
verts=None, edgecolors=None,
37323732
**kwargs):
@@ -3739,8 +3739,8 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
37393739
x, y : array_like, shape (n, )
37403740
Input data
37413741
3742-
s : scalar or array_like, shape (n, ), optional, default: 20
3743-
size in points^2.
3742+
s : scalar or array_like, shape (n, ), optional
3743+
size in points^2. Default is `rcParams['lines.markersize'] ** 2`.
37443744
37453745
c : color, sequence, or sequence of color, optional, default: 'b'
37463746
`c` can be a single color format string, or a sequence of color
@@ -3861,6 +3861,12 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38613861
if x.size != y.size:
38623862
raise ValueError("x and y must be the same size")
38633863

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

38663872
# 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
@@ -3138,7 +3138,7 @@ def quiverkey(*args, **kw):
31383138
# This function was autogenerated by boilerplate.py. Do not edit as
31393139
# changes will be lost
31403140
@_autogen_docstring(Axes.scatter)
3141-
def scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None,
3141+
def scatter(x, y, s=None, c=None, marker='o', cmap=None, norm=None, vmin=None,
31423142
vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,
31433143
hold=None, data=None, **kwargs):
31443144
ax = gca()

0 commit comments

Comments
 (0)