-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow equal aspect box on shared axes #10961
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
Allow equal aspect box on shared axes #10961
Conversation
"0% of diff hit (target 50%)" == complete mystery to me |
|
The problem is that this only gives the desired result because you have carefully chosen your limits to be consistent. I think that allowing this in mpl is bad policy; hence the error. Couldn't you achieve your desired result without sharing? |
I guess I could get the same output with something like
But isn't that restriction a bit artificial? |
I don't think it is artificial; it is preventing an inconsistency. Twinning requires the boxes to be identical, and it locks together the ylim of the two Axes (in the twiny case). Setting the aspect ratio on both means that at draw time, for each Axes in sequence, either its data limits or its box is adjusted. Since the xlims are independent, in your example, this means there is a fundamental conflict between the need to adjust the boxes and the requirement that they be identical. I don't think our API should allow this, even though you can set the xlims so that the boxes would in fact be the same. |
That's probably the main point: Where exactly does this requirement come from? |
Well, I suppose you could superimpose boxes with the same height but different widths, but chances are it would look pretty bad unless you remove the frames. I think it goes against the essence of twinx and twiny, for which a reasonable expectation is that the Axes position boxes coincide.. |
It seems the fundamental desire is to use |
I agree that this is desirable, and at present it not easy in any obvious way that I know of. Everything is so tightly tied to the Axes object, and the Axes object has only a single Locator and Formatter per Axis. Given that, the solution is probably to make a second Axes with everything turned off except for the desired spine, and use callbacks to lock the position and the desired spine limits to those from the master Axes in which the actual plotting is done. The callback for the limits could then transform those numbers (and the entire scale) from centigrade to fahrenheit, for example, or from frequency to period (which would be my use case), and the second Axes Locator and Formatter for the spine would be able to make appropriate ticks and labels. |
maybe this is off-topic and I've misunderstood the root use-case, in which case we can take this elsewhere. Note I'm pretty sure that is the use case in #10960. But... Could we just have a list of |
That might work. It looks like the only use of Axes.transData in the Axis is for an optional tweak, so the subclass could disable it. |
The normal Axis gets its view_interval from its Axes.dataLim. You would change methods in the subclass so that some transformation function would be applied to Axes.dataLim in setting the slave view_interval? |
Of course any general solution to producing secondary axes for images is preferrable compared to this attempted workaround. A meta thing: What you are discussing now goes a bit beyond of the purpose of this PR. If I understand correctly my desired change is rejected. So would it make sense to close this PR and continue general discussion about secondary axes elsewhere, in an issue where it can later be found and used by people implementing those features? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efiring may veto this, but I actually think warning here is fine. The stated use case is completly appropriate, and it appears there is a community out there that uses twinx/y for this purpose. Hopefully no users are going to complain when things look wonky after getting an explicit warning that things may look wonky....
Ooops, approval should be modulo a test checking that the warning is emitted... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still consider this to be bad policy, and would prefer to see the PR closed.
How would this impact situations like subplots(..., sharex=True,
sharey=True)? I find myself wanting to do side-by-side imshow()'s where I
can pan/zoom them together for comparison (think before/after comparisons,
as well as viewing multiple channels). Right now, I have to
set_aspect('equal', adjustable='box-forced') (or something like that, I am
away from my work computer right now). In this case, both the x and y
limits are constrained to be the same, so there never should be an issue,
right? So, does this mean that I can just do "set_aspect('equal')? Could we
not bother with the warning if both axis are shared?
…On Fri, Apr 6, 2018 at 2:59 PM, Eric Firing ***@***.***> wrote:
***@***.**** requested changes on this pull request.
I still consider this to be bad policy, and would prefer to see the PR
closed.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10961 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-HGQbTDFXoa6hz2WWrcXDa3ZzVRIks5tl7ssgaJpZM4TIXqK>
.
|
@WeatherGod, try this, if it is analogous to your use case: fig, ax = plt.subplots(ncols=2, sharex=True, sharey=True)
ax[0].imshow(np.random.randn(15, 12))
ax[1].imshow(np.random.randn(15, 12)) There is no more box-forced; box works in this case. |
oh, when did that happen? I completely missed that! (or completely
forgotten about it...)
…On Fri, Apr 6, 2018 at 10:17 PM, Eric Firing ***@***.***> wrote:
@WeatherGod <https://github.com/WeatherGod>, try this, if it is analogous
to your use case:
fig, ax = plt.subplots(ncols=2, sharex=True, sharey=True)
ax[0].imshow(np.random.randn(15, 12))
ax[1].imshow(np.random.randn(15, 12))
There is no more box-forced; box works in this case.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10961 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-GeFHl_g5TEQ2gJBshb-gMLeTgmtks5tmCHLgaJpZM4TIXqK>
.
|
It was in #10033. |
What's the status here? Should this be closed? Should it be left as a place for discussion? |
I still recommend that it be closed. |
OK, closing this and counting on some other approach to allow for equal aspect doubly sided axes soon. |
PR Summary
This would allow to set an equal aspect box on a shared axes.
Until now the following code
would produce an error. Turning the error into a warning lets this code produce the desired output
PR Checklist