-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Axis swapping method? #6569
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
It is worth investigating. Are you thinking a decorator-style thing |
I think it should happen at the axes level, in order to allow for swapped axes sharing. |
Do you have any examples of how it would work? |
should be equivalent to
|
So
Just a few spontaneous thoughts:
On the first impression, this looks quite rabbit-holy. |
Oh, I definitely agree it'd be kind of a mess :-) |
Huh, I'd have thought you meant the opposite, ax.plot(y0, x0)
ax.hist(..., orientation="vertical")
# <nothing>
ax.plot(x1, y1)
ax.hist(..., orientation="horizontal") i.e., it swaps the Axis and all existing plotted things, but IIRC that's way way harder. |
Well, that's a valid interpretation too... (but yes that looks even harder than my proposal) |
IMO it would be a very nice utility to have. I would expect the latter behaviour, swapping/orientation to be essentially a property of the axes object, so that it would really only "happen" at draw time. Any other interaction with the axes (i.e. plotting) should be "unaware" of it. |
The first case is really hard, the second case is almost impossible, both involving a bunch of state being carried around both by matplotlib and the user in their head, and all just to save the user a bit of cut and paste? I'm 👎 on this. |
While the idea sounds fancy, it is "too clever". I do not think it's possible to implement this in a consistent way across the library. See my comment at #6569 (comment). From an API perspective, I'm also not convinced that swapping axes (either for modifying future drawings ore for flipping the existing plot) is an intuitive way of working. People think of the figure a some sort of paper to draw on, and you'd rather say "draw horizontal bar plot" but not "rotate your paper and draw a bar plot". I'm closing this as non feasible. If anybody wants to advocate this nevertheless, the way forward would be a working implementation for a number existing "rotated" plotting functions ( |
Let's close this as likely too hard; if someone really manages to come up with a reasonable implementation we can always revisit. |
FWIW, this would be particularly useful when used with pandas, which has |
I was wondering whether there was interest in working on an "axis-swapping" API, which would allow an Axes to use its
x
axis as ay
axis and vice-versa (or at least figuring out whether this would be possible). The idea would be to replace all the plotting functions that possess variants where the two axes are swapped (hist(..., orientation="horizontal")
,fill_between
/fill_betweenx
, etc.) as well as those for which such a variant is being proposed (#5856).See also https://mail.python.org/pipermail/matplotlib-devel/2016-June/000472.html (and the earlier messages in the thread), which discuss the usefulness of sharing various pairs of axes among the three axes of a 3D plot with the two axes of a 2D plot (for an interactive orthogonal projection plot). I don't know how well 3D axes support sharing but perhaps this would again be much easier to support with "axes relabeling".
The text was updated successfully, but these errors were encountered: