Skip to content
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

WIP: 1d+2d coord plotting #1737

Merged
merged 2 commits into from
Nov 29, 2017
Merged

WIP: 1d+2d coord plotting #1737

merged 2 commits into from
Nov 29, 2017

Conversation

dcherian
Copy link
Contributor

@dcherian dcherian commented Nov 22, 2017

  • Closes #xxxx
  • Tests added / passed
  • Passes git diff upstream/master **/*py | flake8 --diff
  • Fully documented, including whats-new.rst for all changes and api.rst for new API

This PR teaches plot.contourf() to contour variables with both a 1D co-ordinate (e.g. time) and a 2D co-ordinate (e.g. time-varying depth) da:

<xarray.DataArray 'S' (z: 5, time: 85646)>
array([[       nan,        nan,        nan, ...,        nan,        nan,
               nan],
       [ 35.02816 ,  34.729567,  34.779223, ...,  34.57513 ,  34.671975,
         34.334675],
       [ 35.206943,  35.163239,  34.938674, ...,  34.780728,  34.836331,
         34.70386 ],
       [       nan,  35.184057,  35.10592 , ...,  34.656925,  34.776915,
         34.429442],
       [ 34.85562 ,  34.81994 ,  35.00963 , ...,  35.014522,  34.9747  ,
         35.033848]])
Coordinates:
    depth    (z, time) float16 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 53.5 ...
  * time     (time) datetime64[ns] 2013-12-19T06:00:01 2013-12-19T06:10:01 ...
Dimensions without coordinates: z

Now we can do da.plot(x='time', y='depth')

Couple of questions:

  1. I've added a test, but am not sure how to work in an assert statement.
  2. How do I test that I haven't messed up the syntax in whats-new.rst

@dcherian dcherian changed the title 1d 2d coord plot WIP: 1d+2d coord plotting Nov 22, 2017
@shoyer
Copy link
Member

shoyer commented Nov 22, 2017

@dcherian this sounds great -- can you please comment with an example the plots you can make with this?

I've added a test, but am not sure how to work in an assert statement.

For plotting, we are often OK with just verifying that a plot of some kind is made and there are no errors.

How do I test that I haven't messed up the syntax in whats-new.rst

I'll look over it, but don't worry about this very much -- we check the output manually before releases.

@dcherian
Copy link
Contributor Author

The second call would error out without this PR.

The practical application here is that I have instruments that are moving up and down in the water so the depth of measurement is a function of time.

xarray-1d-2d-plot

Copy link
Member

@fmaussion fmaussion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks!

@shoyer shoyer merged commit 8b08ad8 into pydata:master Nov 29, 2017
@shoyer
Copy link
Member

shoyer commented Nov 29, 2017

Thanks @dcherian !

@dcherian dcherian deleted the 1d-2d-coord-plot branch December 19, 2017 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants