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
Questionable margin-cancellation logic #6565
Comments
After some more thought, I realized that what the proper behavior should be is not obvious. For example, if I display an image and add some annotations on top of it, then it makes sense to not add margins (by default) even if the annotations are very close to the edges. But if the image is just a small part of a larger plot then as explained above it is a bit weird that they have a long "at-distance" effect. Ignoring for now implementation issues, my current best guess at what the proper behavior of margin cancellation should be would be "find the view limits as if margins was zero; then, add margins to each edge that is not in contact with an axes-cancelling artist". Practically speaking, I'm a bit worried that the abstraction and API of #5583 may not be the best one for this (for example it may make sense to also provide the possibility for an artist to indicate that it does not want to be taken into account for autoscaling (#5538)), so perhaps it may make sense, for now, to just directly and manually set the margins to zero when adding an image (or pcolormesh, etc.) to an axes, to avoid later back-compatibility issues? |
Thinking about it again, I now believe that there should just not be any margins cancellation logic in the artist themselves. Basically this is a similar issue as #3946 (should imshow cancel grids?), where it was suggested that if the rcParams have axes.grid set to True then it should not be cancelled upon a call to imshow. |
The top/bottom/left/right thing is to enable I would suggest that when the user explicitly sets |
I think user-set margins should disable the disabling logic for all artists, not just the ones added to that point. Otherwise we have another order-of-operations problem. |
Well, the top/bottom/left/right thing actually doesn't work that well for bars either (see #7175). I still think that rather than rolling out a problematic API in 2.0, we should just call ax.margins(0.2) # or some value read out from the rcparams with the old approach, but for artist in ax.lines + ax.images + ...: artist.set_margins(False) with the new one... which clearly seems more complex for little gain. I'm going to mark this as release critical so that this API is not released with at least one core dev saying "nope, I think this is fine". |
xref'ing that separate left/right margins was proposed also in #1912. |
closed by #7476 |
#5583 lets artists "cancel" the use of margins on an Axes, with the typical use case being images. However, blindly cancelling all margins seem wrong: as of 2.0b1,
results in no margins at the (6, 6) end of the line plot, even though it is well beyond the limits of the image.
Intuitively, it seems instead that the
margins
setting of an artist should simply determine whether its default view limits use margins.The text was updated successfully, but these errors were encountered: