You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
matplotlib.pyplot.scatter should accept "markersize" for consistency #1101
API: changesChanges to the public API, typically requiring deprecation.API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …New featurekeepItems to be ignored by the “Stale” Github Action
I find it confusing that scatter() accepts the keyword argument "s" instead of markersize / ms like plot(). Was this a design choice? If so, why is "size" an invalid option? "s" is simply too ambiguous when other functions such as text() accept an "s" keyword which means string.
I don't see the conflict with "s" as "string" as too bad; the real problem here in my mind is again the unfortunate legacy from Matlab's scatter function in which all Collection "size" scaling is based on the square root of the "size" parameter instead of the parameter itself. In other words, this early bad design choice is deeply embedded.
Your suggestion of allowing a "markersize" (presumably with alias, "ms") kwarg may provide a good route out of this Matlab trap, although it is not the greatest name for the scale parameter for Collections in general. Certainly it makes good sense for scatter, though.
Within matplotlib itself, it's relatively easy to rewrite the size to be a linear scale. Would it be acceptable given the backwards compatibility concerns? If I understand correctly, pyplot is designed to provide as close of a copy of Matlab interface. If so, the best solution, I guess, would be to have Collectionssizes argument a linear scale, Axes.scattersizes also linear, and pyplot.scatters being area. It would be preferential, however to also provide a pure OO GUI interface as well (right now it's very hard without pyplot).
Not exactly. I think the thing to do is leave them both open. Your comment links them, so that anyone wanting to work on one will see the discussion on the other.
On the call today we discussed this and reached a consensus that this should be worked on. An idea discussed to start out with was to add a kwarg that would set the marker sizes in linear scale instead of the quadratic being done right now and if both s and markersize (or whatever we decide to call it) are provided then we error out as quickly with a detailed error message about it. The current state of action will be to first check the feasibility of implementing this. If this starts becoming unnecessarily complicated, we will rethink this.
I think we need to decide on if we want to make this just a thing for scatter or an inherent property of _CollectionWithSizes. If we want to do it just for scatter then we can work around by handling the kwarg in the scatter function and "setting" the sizes as the squared value of the kwarg but this will create an inconsistency between what was set and what would be returned/used get_sizes/set_sizes.
On the other hand, we can create a new scaling (placeholder name) attribute for _CollectionWithSizes that determines if the size was set with a linear scale or a quadratic scale and then sets the sizes with/without the np.sqrt(self._sizes) call. This way it gets handled by _CollectionWithSizes and can be extended to all the derived classes. I have a toy implementation for this if it sounds like something we want to do. It requires changes in _axes.py, collections.py, and mplot3d/art3d.py to handle 3D scatter.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
API: changesChanges to the public API, typically requiring deprecation.API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …New featurekeepItems to be ignored by the “Stale” Github Action
Activity
efiring commentedon Aug 17, 2012
I don't see the conflict with "s" as "string" as too bad; the real problem here in my mind is again the unfortunate legacy from Matlab's scatter function in which all Collection "size" scaling is based on the square root of the "size" parameter instead of the parameter itself. In other words, this early bad design choice is deeply embedded.
Your suggestion of allowing a "markersize" (presumably with alias, "ms") kwarg may provide a good route out of this Matlab trap, although it is not the greatest name for the scale parameter for Collections in general. Certainly it makes good sense for scatter, though.
akhmerov commentedon Aug 18, 2012
Within matplotlib itself, it's relatively easy to rewrite the size to be a linear scale. Would it be acceptable given the backwards compatibility concerns? If I understand correctly,
pyplotis designed to provide as close of a copy of Matlab interface. If so, the best solution, I guess, would be to haveCollectionssizesargument a linear scale,Axes.scattersizesalso linear, andpyplot.scattersbeing area. It would be preferential, however to also provide a pure OO GUI interface as well (right now it's very hard withoutpyplot).dmcdougall commentedon Aug 21, 2012
Schematically, is the following a good idea?
Inside the
Axes.scattermethod:The idea is that if the user specifies
markersize, the size of the points will be as for aLine2Dobject. Otherwise, the old area scale code is used.story645 commentedon May 31, 2016
does dealing with this simultaneously deal with #1099? (they're sort of addressing the same issue from two different sides)
efiring commentedon May 31, 2016
Yes, any action dealing with either should address both of them.
story645 commentedon May 31, 2016
so at that point are they dupes?
efiring commentedon May 31, 2016
Not exactly. I think the thing to do is leave them both open. Your comment links them, so that anyone wanting to work on one will see the discussion on the other.
chahak13 commentedon Feb 10, 2023
On the call today we discussed this and reached a consensus that this should be worked on. An idea discussed to start out with was to add a kwarg that would set the marker sizes in linear scale instead of the quadratic being done right now and if both
sandmarkersize(or whatever we decide to call it) are provided then we error out as quickly with a detailed error message about it. The current state of action will be to first check the feasibility of implementing this. If this starts becoming unnecessarily complicated, we will rethink this.cc: @tacaswell @efiring @jklymak @ksunden @melissawm @timhoffm @rcomer (Tim, tagging you since this would entail an API change probably)
chahak13 commentedon Feb 19, 2023
I think we need to decide on if we want to make this just a thing for
scatteror an inherent property of_CollectionWithSizes. If we want to do it just for scatter then we can work around by handling the kwarg in the scatter function and "setting" the sizes as the squared value of the kwarg but this will create an inconsistency between what was set and what would be returned/usedget_sizes/set_sizes.On the other hand, we can create a new
scaling(placeholder name) attribute for_CollectionWithSizesthat determines if the size was set with a linear scale or a quadratic scale and then sets the sizes with/without thenp.sqrt(self._sizes)call. This way it gets handled by_CollectionWithSizesand can be extended to all the derived classes. I have a toy implementation for this if it sounds like something we want to do. It requires changes in_axes.py,collections.py, andmplot3d/art3d.pyto handle 3D scatter.github-actions commentedon Feb 21, 2024
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!