| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
"0% of diff hit (target 50%)" == complete mystery to me |
Sorry, something went wrong.
|
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
I guess I could get the same output with something like from matplotlib import pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(111, label="a")
ax2 = fig.add_subplot(111, label="b")
ax1.imshow([[0,1],[1,0]], extent=(0,5,10,20))
ax2.tick_params(left=False, bottom=False, top=True,
labeltop=True, labelbottom=False,
labelleft=False)
ax2.set_aspect("equal", adjustable="box")
ax2.patch.set_visible(False)
ax2.axis([36,41,10,20])
plt.show()
But isn't that restriction a bit artificial? |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
That's probably the main point: Where exactly does this requirement come from? |
Sorry, something went wrong.
|
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.. |
Sorry, something went wrong.
|
It seems the fundamental desire is to use twiny is to provide a second x-spine for the original axes that will have different locators and formatters (an alternate scale), rather than create a second axes that will be plotted on. Is there any other way to achieve that right now? |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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 secondary_xaxis and secondary_yaxis objects that are just subclasses of xaxis objects but also have the "unit" conversion, have an offset of some sort, and are slave to their parent x/yaxis? These could simply be updated every time the parent axes is updated, but would have a known parent (the backwards compatible Axes.xaxis)? I say a list, because if we allow one extra spine, why not more. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
|
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? |
Sorry, something went wrong.
There was a problem hiding this comment.
@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....
Sorry, something went wrong.
|
Ooops, approval should be modulo a test checking that the warning is emitted... |
Sorry, something went wrong.
There was a problem hiding this comment.
I still consider this to be bad policy, and would prefer to see the PR closed.
Sorry, something went wrong.
|
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>
.
|
Sorry, something went wrong.
|
@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. |
Sorry, something went wrong.
|
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>
.
|
Sorry, something went wrong.
|
What's the status here? Should this be closed? Should it be left as a place for discussion? |
Sorry, something went wrong.
|
I still recommend that it be closed. |
Sorry, something went wrong.
|
OK, closing this and counting on some other approach to allow for equal aspect doubly sided axes soon. |
Sorry, something went wrong.
|
#11026 is heading that way, though I am planning to stop where I am with that and will add the second slave axes as a different PR once #11026 is in (if its deemed acceptable). Its a little bit orthogonal, with the only relevant addition being the ability to add an axes child... |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
This would allow to set an equal aspect box on a shared axes.
Until now the following code
from matplotlib import pyplot as plt fig, ax1 = plt.subplots() ax2 = plt.twiny() ax1.imshow([[0,1],[1,0]], extent=(0,5,10,20)) ax2.set_aspect("equal", adjustable="box", share=True) ax2.axis([36,41,10,20]) plt.show()would produce an error. Turning the error into a warning lets this code produce the desired output
PR Checklist