-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Wedged polar plot's position/scaling leaves too much white space. #10264
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
This is expected (by me because I wrote it) behaviour, though not really desired. Polar plots set themselves to have equal aspect by default. This is only done in Since the space for the Axes is provided by the Figure, I never really knew how to get it to resize itself, and still don't really know. If anyone knows, I'd like to find out, because it's something that seems desirable in other places, like Cartopy for instance. |
This seems like something a constrained layout manager might be able to
handle? Maybe somewhat?
Allowing a plot to resize a figure is currently a big no-no in matplotlib.
It is technically possible, but it would be a really bad idea in practice.
What I do personally is to call matplotlib.figure.figaspect() to give me a
reasonable figure size ahead of time.
…On Wed, Jan 17, 2018 at 7:57 PM, Elliott Sales de Andrade < ***@***.***> wrote:
This is expected (by me because I wrote it) behaviour, though not really
desired. Polar plots set themselves to have equal aspect by default. This
is only done in __init__ though, so wedges are simply zoomed as much as
possible to fit in that square box.
Since the space for the Axes is provided by the Figure, I never really
knew how to get it to resize itself, and still don't really know. If anyone
knows, I'd like to find out, because it's something that seems desirable in
other places, like Cartopy for instance.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10264 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-IkvVWW25Sz1z_QMzaoEwYnwnllvks5tLpcUgaJpZM4RiMhQ>
.
|
Well, it's not resizing the Figure that's needed, "just" resizing the space needed for the Axes. But I think that's still managed by the Figure itself, no? |
I have to admit that my understanding of the internals is rather limited. But since normal image subplots are handled exactly as desired (i.e. their axes size is as large as the image itself by default) I would have thought that there is a mechanism that provides this behaviour and which can be used here as well. |
First there is a constrained layout manager PR #9082.
The space that the axes is being drawn is set by get_position(original=False) . (please see #9855 which fixes this, but hasn't been reviewed yet).
I don't know the internals of the polar projection. if I was just drawing half a circle on a Cartesian projection, I'd set the I'd need to play w/ the above, but it seems maybe polar projection should have some awareness of the extent it wants to draw over and modify its transform accordingly. It may need to modify the "active" axis position as well, but I don't know how polar does that at the moment. |
|
Yeah, and I don't understand the Transforms. Whats happening now is that I think that aspect should be changed from 1 to 0.5 (in the present case, or whatever fraction of the circle is being made) and the y part of the transform multiplied by 2.0. If I |
Yes, I've found something similar. Partially, the problem is in the wedge bbox here because it tries extra hard to get equal aspect ratio. I can set aspect ratio in |
excellent |
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! |
Any updates? |
Any updates in merging this PR? |
Coming from this stackoverflow question, some strange (to me) behaviour is observed when plotting partial or wedged polar plots. This new feature, which can be used by setting
.set_thetamin
and.set_thetamax
on a polar plot, allows to plot only part of a polar plot without the need to use floating axes - which is of course a great feature.The problem arises when either using those partial polar plots as subplots or when trying to plot them tightly in a figure. It seems like their position is always set to be in the middle of some kind of subplot with aspect ratio of 1. Especially when using a half circle polar plot, this causes a lot of unnecessary white space around the half-circle.
Consider this code:
which produces the top plot in the below image. I have manually marked the region which is occupied by the polar plot, calling it "Incompressible BBox", because it occupies much more space than desired, also making the xlabel appearing totally off. The picture below is what I would expect this subplot to behave like.
The "imcompressibility" of that box also prevents to have such a half-circle polar plot tight in a figure.
In the following code a simple figure with such a plot is attempted.
The plot appears much smaller than the figure would allow for and leaves a lot of white space around.
The only workaround I can currently think of is to make the original axes much larger than the figure (
ax.set_position( [0.1, -0.45, 0.8, 2])
) and shift the xlabel manually by some amount towards the top, as shown in the lower picture. Workaround code.I guess this behaviour is in general undesired. One would rather have either the same behaviour as for fixed aspect plots (like imshow, i.e. what is called "compressible" above) or even better, some API to set the position to useful values according to the usual subplot mechanism.
The text was updated successfully, but these errors were encountered: