-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Issues with autoscaling and transforms with 3.2+ #17016
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
Comments
I think this is basically an instance of #13642 (comment), which I did not realize would affect many people, otherwise I'd have insisted more on it. (On the other hand, I did look a bit into it a while ago and IIRC fixing that was not so trivial :/) The basic idea of #13642 was that previously, when autoscaling a Collection (e.g., a PatchCollection as producted by scatter()), we would attempt to take the marker extents into account (i.e., we'd have 5% margins starting from the edges of the markers rather than their centers). Clearly there are some issues to make that work -- the most obvious one being what happens if the marker size is bigger than the axes size(!); see the discussion in that issue for more examples. Also it seems weird that e.g. So we decided that for collections whose size was in physical space (i.e. points), their extents would not be included in autoscaling (I still think that change is fundamentally for the better). Clearly, if a collection is in data space (i.e., x values), then they should still be taken into account, and they correctly are. What we did not handle was collections for which only x or only y was in data space -- as per my comment linked above, we handled them as fully in physical space. This is exactly the blended transform case you show here. Ideally, we'd want to handle the x and y axis separately (include them in autoscaling along the data-space direction, but not along the screen-space direction); if someone wants to look into this that would be great! However, in the mean time, I guess a partial solution would be to just handle them as if fully in physical space, which should approximately just be a matter of replacing |
Thanks a lot for the simple example. The fix in #17017 fixes this very naively. Not sure if its the "correct" fix. |
Bug report
Bug summary
I am encountering a few seemingly related issues but can't exactly define what's happening. They broadly relate to unexpected changes in how plots are scaled and appear in the context of using the transform objects attached to the Axes. I assume they are caused by changes in autoscaling in 3.2, but don't know whether they are a bug or if previous code was relying on undefined behavior (the release notes are a little vague about what actually changed).
Code for reproduction
Here is a simple example derived from an issue in seaborn rugplot (mwaskom/seaborn#2015)
Actual outcome
With matplotlib 3.2.1:
Expected outcome
With matplotlib 3.1.2:
Matplotlib version
print(matplotlib.get_backend())
): ipython inlineOther information
Linking another seaborn issue (mwaskom/seaborn#2013) where there has been a similar change in behavior with matplotlib 3.2 but where it's harder to extract a standalone issue.
The text was updated successfully, but these errors were encountered: