-
-
Notifications
You must be signed in to change notification settings - Fork 7.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 our terms of service and privacy 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?
Conversation
I think this misses the semantic difference between First, I don't think you should snake the scaling through to the low-level object. get_sizes should just return what it's always returned, with an explanation in the docs. Second, I think you should consider that |
My only concern with this is if the user has provided the sizes in the linear scale, then it makes sense to return the sizes that were "set" instead of the modified ones. But this goes hand in hand with the discussion of what we want There are two things that the original issue/discussion covered: 1. Having I agree with not allowing both |
My tendency is to be pretty conservative when it comes to multiple ways to do the same thing. I'd be very concerned about the Container returning different values for size based on how the axes helper created it. Yes, you have a new flag on the Container, but downstream libraries don't know that, so if anyone is depending on the markersize being in one units or another, they are not going to know to check the markerscale. |
I understand that, but wouldn't having the default behaviour such that it doesn't change anything that already exists resolve that issue? And if they are instead using |
Meeting 9/3: Think instead about making |
@chahak13 does this still need discussion or do you have enough guidance? |
@jklymak sorry, I should've put a comment in earlier but I've changed |
Sorry for the label, was looking for something else! |
markersize
kwarg for scatter52e4073
to
0abd1b7
Compare
472aef6
to
34c0620
Compare
34c0620
to
75c0084
Compare
Needs the aliases added to the mypy-stubtest-allowlist.txt file: matplotlib/ci/mypy-stubtest-allowlist.txt Line 85 in 7f50e7a
Since aliases are dynamically generated, they are not type hinted. Users wanting to use static type checking should use the canonical name (which is a pretty fair tradeoff, and usually results in more readable code, aliases are more helpful for interactive work where using short names or not needing to remember "is there an s on this function?" is more useful) Adding to the list is just how we silence stubtest, which looks at what is included at runtime. |
Ah, the conflict is because since this was opened I actually started dynamically finding aliases so they don't need to be in the |
@@ -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`). | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not call this *scale
, because it could be interpreted as "linear scaling factor" - and we do this e.g. at mutation_scale
in https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.FancyArrowPatch.html#matplotlib.patches.FancyArrowPatch. Suggestion: markerscaling
or maybe just scaling
- I have some sympathy to push this down to collectionWithSizes
later. A scaling
parameter would be meaningful there so that we have consistent naming and don't need to translate the markerscaling kwarg. Also, I believe scatter(..., scaling=...)
is clear enough.
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.
PR Summary
Issue #1101 talks about having a kwarg calledmarkersize
for the scatter function that can take sizes on a linear scale since it is currently on a quadratic scale with the kwargs
. This PR adds a new kwarg toscatter
calledmarkersize
and adds the_markerscale
attribute to_CollectionWithSizes
. Using these, the size of the markers can be set with a linear scale. The default is still to use thes
parameter if nothing is given and markersizes are used only if specifically provided instead ofs
.After discussion, the scope was changed to adding
markersize
as an alias tos
in scatter and add a variablemarkerscale
that will allow the linear/quadratic scaling for the size values.PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst