Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature plotting #466

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

Merged
merged 62 commits into from
Jul 20, 2015
Merged

Feature plotting #466

merged 62 commits into from
Jul 20, 2015

Conversation

clarkfitzg
Copy link
Member

Not complete, but still ready for some feedback!

Docs are built here:
http://xray.readthedocs.org/en/feature-plotting/plotting.html

There are several TODOs around the docs and the code base. For some of these I'm requesting specific feedback.

Still need to:

  • Handle NaN's
  • Informative TypeError for coords that can't be plotted

a.plot()

It may seem strange that
the the values on the y axis are decreasing with -0.5 on the top. This is because
Copy link
Member

Choose a reason for hiding this comment

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

the the

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

# Lists need to be converted to np.arrays here.
if not any(_right_dtype(np.array(x), plottypes) for x in args):
raise TypeError('Plotting requires coordinates to be numeric '
'or dates. Try DataArray.reindex() to convert.')
Copy link
Member

Choose a reason for hiding this comment

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

reindex is not a method that converts string labels to numbers:
http://xray.readthedocs.org/en/stable/indexing.html#align-and-reindex

I would suggest DataArray.assign_coords to assign new coordinate labels.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@savefig plotting_example_time.png width=6in
noise.plot_line()

TODO- rotate dates printed on x axis.
Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't plotting well.

@jhamman
Copy link
Member

jhamman commented Jul 18, 2015

I'm going to get around to testing this out tomorrow. I just breezed through the docs and I have one comment. Can we not use jet as the default colormap? I know it is the default colormap in matplotlib but we aren't bound by that. There are dozens of sources out there explaining why jet is a bad choice. I'll give two of the ones that have popped out to me over the years:

There is also a lively Github issue over here: matplotlib/matplotlib#875

I'll try to get a few more comments out tomorrow. So far, this work is really encouraging.

@nbren12
Copy link
Contributor

nbren12 commented Jul 18, 2015

I agree that jet isn't a good color scheme (this scipy talk is really
good https://www.youtube.com/watch?v=xAoljeRJ3lU), but that is easily
changed by setting cmap='whatever'.

One colorbar issue I find consistently annoying is having to manually
specify vmin and vmax or levels when plotting anomaly fields on a
diverging colorbar with white in the middle. Some sort of
symmetric_colorbar= <middle point value> kwarg would be really nice.

@shoyer
Copy link
Member

shoyer commented Jul 18, 2015

@jhamman I'd be happy to bundle viridis with xray as the default colormap (the source code is here) -- or we could just wait a few months, at which time it will be the matplotlib default.

@nbren12 Seaborn has some heuristics for picking sequential vs diverging colormaps. Possibly worth borrowing: https://github.com/mwaskom/seaborn/blob/v0.6.0/seaborn/matrix.py#L158

My inclination is to merge this on master and iterate in future PRs. There are still a few things to fix, but this is a great start.

@jhamman
Copy link
Member

jhamman commented Jul 18, 2015

yeah, +1 for the viridis colormap.


distance = np.linalg.norm(xy, axis=2)

distance = xray.DataArray(distance, zip(('y', 'x'), (y, x)))
Copy link
Member

Choose a reason for hiding this comment

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

list(zip(..)) for python3 compatibility?

@jhamman
Copy link
Member

jhamman commented Jul 18, 2015

@clarkfitzg - I just spent some time running through your examples and trying to plot some of my own data. Overall - this is really slick and I really liked what you have going here. Below are a few comments I made along the way - take them or leave them.

  1. Consider yincrease=True as the default. Maybe there is a downside to this but I don't see it. I'm pretty sure it is just the convention of imshow.
  2. It may be worth mentioning why you are using imshow over pcolormesh. The limitation of imshow having regularly spaced coordinates will be important to some (myself included). We may, at some point, want to add an option for using pcolormesh. This would support irregular grids without forcing the use of contourf.
  3. More examples with cartopy would be good. Maybe we can put together example page here: http://xray.readthedocs.org/en/latest/examples.html
  4. I continue to have cartopy install problems on osx, even with python2.7 using anaconda. I also had problems on a clean docker image. I know this has nothing to do with this PR but the problems with installing cartopy will limit its applicability here.

@shoyer
Copy link
Member

shoyer commented Jul 18, 2015

Have you tried the ioos conda channel for cartopy? They do a really nice job maintaining builds.

On Sat, Jul 18, 2015 at 11:30 AM, Joe Hamman [email protected]
wrote:

@clarkfitzg - I just spent some time running through your examples and trying to plot some of my own data. Overall - this is really slick and I really liked what you have going here. Below are a few comments I made along the way - take them or leave them.

  1. Consider yincrease=True as the default. Maybe there is a downside to this but I don't see it. I'm pretty sure it is just the convention of imshow.
  2. It may be worth mentioning why you are using imshow over pcolormesh. The limitation of imshow having regularly spaced coordinates will be important to some (myself included). We may, at some point, want to add an option for using pcolormesh. This would support irregular grids without forcing the use of contourf.
  3. More examples with cartopy would be good. Maybe we can put together example page here: http://xray.readthedocs.org/en/latest/examples.html

1. I continue to have cartopy install problems on osx, even with python2.7 using anaconda. I also had problems on a clean docker image. I know this has nothing to do with this PR but the problems with installing cartopy will limit its applicability here.

Reply to this email directly or view it on GitHub:
#466 (comment)

@clarkfitzg
Copy link
Member Author

Thanks for all the feedback! I'll change the default colormap and look into the other things mentioned on Monday.

Re Python 3 compatibility with xray.DataArray(d_ylog, zip(('y', 'x'), (y, x))) it would be nice if the DataArray constructor accepted an iterable. Thoughts?

@shoyer
Copy link
Member

shoyer commented Jul 19, 2015

Re Python 3 compatibility with xray.DataArray(d_ylog, zip(('y', 'x'), (y, x))) it would be nice if the DataArray constructor accepted an iterable. Thoughts?

Agreed. Want to add a fix?

@clarkfitzg
Copy link
Member Author

Sure. I'll do it separate from this PR.

shoyer added a commit that referenced this pull request Jul 20, 2015
@shoyer shoyer merged commit 1faf1b2 into master Jul 20, 2015
@shoyer
Copy link
Member

shoyer commented Jul 20, 2015

Let's follow up on this with some smaller PRs.

@clarkfitzg
Copy link
Member Author

@jhamman

  1. The issue with yincrease=True as the default is that actual PNG images when loaded will be 'upside down' when plotted with xray.
  2. Definitely could add support for pcolormesh. Went with imshow since it seems more common.
  3. +1
  4. I recently installed cartopy on a new machine with conda:
conda install -c scitools cartopy

Seems like it used an old version of matplotlib, but it still worked.
Followed their docs: http://scitools.org.uk/cartopy/docs/latest/installing.html

@clarkfitzg clarkfitzg deleted the feature-plotting branch July 20, 2015 17:47
@clarkfitzg clarkfitzg mentioned this pull request Aug 18, 2015
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.

4 participants