Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Allow linear scaling for marker sizes in scatter#25259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
8492445
46b3bff
e9f33bb
1c9576d
c46095b
dabe428
2c95f38
75c0084
1b0a4f4
3cfecf9
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
``markersize`` and ``markerscale`` added to scatter | ||
--------------------------------------------------- | ||
``markersize`` is new alias for ``s`` in scatter that can be used to set the size of | ||
the markers. The marker sizes can now also be set using a linear scale using the | ||
``markerscale`` parameter. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4476,7 +4476,7 @@ def invalid_shape_exception(csize, xsize): | ||
@_docstring.interpd | ||
def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, | ||
vmin=None, vmax=None, alpha=None, linewidths=None, *, | ||
edgecolors=None, plotnonfinite=False,markerscale=2,**kwargs): | ||
""" | ||
A scatter plot of *y* vs. *x* with varying marker size and/or color. | ||
@@ -4568,6 +4568,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, | ||
or ``nan``). If ``True`` the points are drawn with the *bad* | ||
colormap color (see `.Colormap.set_bad`). | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I would not call this Also, 1 and 2 are not very telling as values. How about "linear"/"quadratic" or "linear"/"square" or "length"/"area"? Edit: There seems to be a mismatch between the discussion and code whether to push the scaling down to CollectionWithSizes. I've written the above under the impression that pushing down should not (yet?) be done in this PR. - Rethinking, I claim that pushing down is very much to be preferred - not being able to reflect the high-level scaling concept in the underlying artists would be a major shortcoming. I'm +1 on implementing this immediately in CollectionWithSizes. | ||
markerscale : 1 or 2, optional, default: 2 | ||
Scaling factor used to set the size as points or points**2. | ||
Default value is set as 2 to set the size values as points**2. | ||
.. versionadded:: 3.9 | ||
Returns | ||
------- | ||
`~matplotlib.collections.PathCollection` | ||
@@ -4607,9 +4613,17 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, | ||
if x.size != y.size: | ||
raise ValueError("x and y must be the same size") | ||
if s is not None and 'markersize' in kwargs: | ||
raise ValueError( | ||
"Only one of `s` or `markersize` should be passed. " | ||
"Please refer to the docs for more details about usage.") | ||
if s is None: | ||
if 'markersize' not in kwargs: | ||
s = (20 if mpl.rcParams['_internal.classic_mode'] else | ||
mpl.rcParams['lines.markersize'] ** 2.0) | ||
else: | ||
s = kwargs.pop('markersize') | ||
s = np.ma.ravel(s) | ||
if (len(s) not in (1, x.size) or | ||
(not np.issubdtype(s.dtype, np.floating) and | ||
@@ -4696,6 +4710,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None, | ||
collection = mcoll.PathCollection( | ||
(path,), scales, | ||
markerscale=markerscale, | ||
facecolors=colors, | ||
edgecolors=edgecolors, | ||
linewidths=linewidths, | ||