Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
chahak13 wants to merge10 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromchahak13:scatter_markersize

Conversation

chahak13
Copy link
Contributor

@chahak13chahak13 commentedFeb 19, 2023
edited
Loading

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 addingmarkersize 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

  • Has pytest style unit tests (andpytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a.. versionadded:: directive in the docstring and documented indoc/users/next_whats_new/
  • API changes are marked with a.. versionchanged:: directive in the docstring and documented indoc/api/next_api_changes/
  • Release notes conform with instructions innext_whats_new/README.rst ornext_api_changes/README.rst

@chahak13chahak13 marked this pull request as ready for reviewFebruary 26, 2023 03:10
@jklymak
Copy link
Member

I think this misses the semantic difference betweens inscatter andmarkersize inplot. Inscatter,s is meant to be an array inscatter, whereasmarkersize cannot be an array inplot. I think the changes proposed here make the difference even more confusing, and we should be very deliberate about what we do here.

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 thats=array is how to specify arrays for the markersizes, andmarkersize=float is a shortcut forplot-like scaling ifs is not provided. eg,markersize shouldnot accept an array. Ifs andmarkersize are both specified, it should probably error out.

@chahak13
Copy link
ContributorAuthor

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.

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 wantmarkersize to be doing.

There are two things that the original issue/discussion covered: 1. Havingmarkersize (or better) as a more user-friendly kwarg and 2. To provide a way to have linearly scaling sizes. For 2, it makes more sense to me to be able to add an array formarkersize than to not because that is taking away functionality that can be provided without much effort. If the consensus is to not allow arrays, then that should not be difficult.

I agree with not allowing boths andmarkersize at the same time. It does that already, that's the first check.

@jklymak
Copy link
Member

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.

@chahak13
Copy link
ContributorAuthor

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 usingmarkersize then they would know already what will be returned based on the docs?

@chahak13
Copy link
ContributorAuthor

Meeting 9/3: Think instead about makingmarkersize an alias fors and have a scaling factor as the kwarg to control all this. Also look into how to make this scaling factor consistent with all the getter/setters.

@jklymak
Copy link
Member

@chahak13 does this still need discussion or do you have enough guidance?

@chahak13
Copy link
ContributorAuthor

@jklymak sorry, I should've put a comment in earlier but I've changedmarkersize to be an alias fors and added amarkerscale variable as we discussed last time in the meeting.

@chahak13
Copy link
ContributorAuthor

Sorry for the label, was looking for something else!

@chahak13chahak13 changed the titleImplement amarkersize kwarg for scatterAllow linear scaling for marker sizes in scatterApr 27, 2023
@chahak13chahak13 marked this pull request as draftApril 27, 2023 03:48
@ksunden
Copy link
Member

Needs the aliases added to the mypy-stubtest-allowlist.txt file:

# Aliases (dynamically generated, not type hinted)

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.

chahak13 reacted with thumbs up emoji

@chahak13chahak13 marked this pull request as ready for reviewMay 11, 2023 22:23
@ksunden
Copy link
Member

Ah, the conflict is because since this was opened I actually started dynamically finding aliases so theydon't need to be in themypy-stubtest-allowlist.txt file any more

@@ -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`).

Copy link
Member

@timhoffmtimhoffmFeb 22, 2024
edited
Loading

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. atmutation_scale inhttps://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.FancyArrowPatch.html#matplotlib.patches.FancyArrowPatch. Suggestion:markerscaling or maybe justscaling - I have some sympathy to push this down tocollectionWithSizes later. Ascaling parameter would be meaningful there so that we have consistent naming and don't need to translate the markerscaling kwarg. Also, I believescatter(..., 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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm left review comments

@greglucasgreglucasgreglucas left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@chahak13@jklymak@ksunden@timhoffm@greglucas

[8]ページ先頭

©2009-2025 Movatter.jp