-
Notifications
You must be signed in to change notification settings - Fork 296
Allow 1D plots to have the coordinate on the y-axis. #582
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
Conversation
I gave it a little though this morning. How about taking a lead from matplotlib's api? I'm thinking of pcolormesh where the x and y args are optional:
How about if we did something similar where iris.plot.plot(cube, cube.coord('depth')) or (what I need right now) iris.plot.plot(cube.coord('time'), cube.coord('depth')) We'd need to be careful to handle the 1d/2d coordinate cases. What do you think @ajdawson? |
Is there much point doing this for For 1D plots this could work perhaps. However as I said previously my interpretation of the |
👍 I think this would even work for 2D coords in either order. |
@ajdawson - I don't want to hijack your PR, but I wanted to propose an alternative. I'm not wedded to doing it for 2d plots, that's just where the thought originated. However, I do need to be able to do this: iris.quickplot.plot(cube.coord('time'), cube.coord('depth')) At the moment I can dig out the name/symbol/units and label the axes appropriately and pull out the points arrays and call |
Can you just explain to me what the time and depth coordinates are. |
Thanks for the examples. The requirements for this functionality are certainly a lot more advanced than I had envisioned. I doubt I'll have time to do this though, so if this route is the popular one I'll close this PR and let some one else start a new one on this? |
Can anyone suggest examples of where using |
It won't do the wrong thing currently, but it will miss out loads of vertical coordinates (anything not convertible to hPa or having a positive attribute). I was concerned that expanding this may lead to false positives. Unless you can be sure you are going to identify most (all ideally) vertical coordinates correctly I think this is a little risky. |
At the moment I still like @esc24's idea. But it'd be good if we can keep as much benefit from this PR as possible. In that context, if the new "transpose" keyword was replaced with an is-vertical test this PR would make a nice stepping-stone.
I've just refreshed my memory of the CF definition of vertical coordinates and you're right. There a gaping great whole in the CF spec where it talks about "providing the
It would be risky if this was all we were going to do, but if we went on to implement @esc24's suggestion (or similar) then I think that risk goes away. (Also, any improvement on the "appropriate" standard names issue would help minimise the number of cases where the is-vertical test does the wrong thing.) |
I agree, I was referring to handling this automatically rather than the other suggestions. |
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.
Quick brain-dump:
There was a conversation a while ago to allow users to pick the dimension of the data to plot (I think the syntax was something like coords=('dim1', 'time')
) I don't necessarily like the proposal, but I do think the functionality would be useful. An extension to this capability that I have thought of a couple of times would be to allow users to specify "data" in some way as one of the plot axis. Using this same clunky syntax that might look like coords=('data', 'time')
.
Having such a capability would allow one to define the coordinate order of the plot without the need for the boolean keyword argument.
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.
Having such a capability would allow one to define the coordinate order of the plot without the need for the boolean keyword argument.
@esc24 and I touched on the data-token idea when we were discussing his proposal. But as things stand I'd rather we take the route he proposed on this PR.
I've changed my mind! I've knocked up a quick prototype of this idea for |
Does anyone have any thoughts on the following: The new plot function will accept one or two arguments. In the case of the quickplot version, what should the title of the plot be when two input arguments are used and they are:
|
@esc24 is that balloon file able to be used for test data? If not I'll construct something similar. |
Nevermind, it looks like the newly added NAME trajectory data. |
Well spotted, |
This PR adds an optional argument to the
iris.plot.plot
andiris.quickplot.plot
functions that allows the coordinate to be presented on the y-axis of a 1D plot (see #581). This is necessary in order to make profile plots with iris, these types of plots are extremely common in meteorology and oceanography (temperature/salinity/velocity profiles in the ocean, temperature profiles in the atmosphere to name a few examples).Implementation notes:
This change is implemented as a new boolean keyword argument. I am aware that this is not to many people's taste, but having explored other options I felt this was the best way to go for the following reasons:
iris.quickplot
needs to know how to draw the plot labels, so the information needs to be available at that level._draw_1d_from_points
makes life easier for other modifications (e.g., y-axis inversion for vertical coords #522) since they can easily tell if the axes will be transposed.I'd appreciate some feedback on this. If anyone has a better way of doing this that remains flexible I'd be happy to hear it.