-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Plotting datasets with variable coordinates #1503
Comments
On 08/06/2017 11:37 PM, Sam Miller wrote:
Is the behavior that xarray is showing by design or is it a corner
case that I'm getting because I'm not using xarray in the way it was
originally intended?
Xarray follows the CF conventions as far as possible, and the convention
states that dimension coordinates should have the same name as their
dimension. See the docs for terminology:
http://xarray.pydata.org/en/latest/data-structures.html#coordinates
What we could do however is to add a "x" kwarg to plot.line so that one
can specify which coordinate to use for the plot, like plot.pcolormesh
i.e. it would be possible to do:
ds.variable.plot(x='r')
Instead of renaming the dimension for it to become a dimension coordinate.
Thoughts?
Cheers,
Fabien
|
I think that would work. I've just been trying to understand what the CF conventions mean for me in my use case, where I have a grid that moves over time, but keeps the same number of nodes and cells. I feel like xarray could be a big help, but I'm still trying to figure it out. Thanks for the quick responses here and on SO. |
Does this work now? |
No it doesn't! Your most recent PR still checks for the kwarg in dims, not in coordinates. |
Shall I send in a PR to check |
To follow up with this, plotting using 'x' and 'y' kwargs works fine for now, even when the variable coordinates do not share the same number of dimensions. (i.e., a common case of plotting a cross section with sigma- or s-coordinates where the horizontal variable is 1D, but the vertical variable is 2D). So, I think this great, and should cover most use cases. The only approach I can think of to do this automatically would be to find variable coordinates that have matching dimensions. This would probably work in lots of cases, but unexpectedly break in others. I think I would prefer explicit over clever, unless we can think of a way to do it that won't break. |
I'm trying to plot a dataset that has variable coordinates, and am getting behavior that is unexpected, and I wonder if it is a design issue or a user issue (i.e. I don't grok xarray). I've posted the question on SO (https://stackoverflow.com/questions/45474153/plotting-xarray-datasets-with-variable-coordinates).
Is the behavior that xarray is showing by design or is it a corner case that I'm getting because I'm not using xarray in the way it was originally intended?
The text was updated successfully, but these errors were encountered: