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

Adding surface plot for 2D data #2235

Closed
TomNicholas opened this issue Jun 16, 2018 · 2 comments
Closed

Adding surface plot for 2D data #2235

TomNicholas opened this issue Jun 16, 2018 · 2 comments

Comments

@TomNicholas
Copy link
Member

I am interested in adding the ability to plot surface plots of 2D xarray data using matplotlib's 3D plotting function plot_surface().

This would be nice because a surface in 3D is much more useful for showing certain features of 2D data then color plots are. For example an outlier would appear as an obvious spike rather than just a single bright point as it would when using plot.imshow(). I'm not suggesting adding full 3D plotting capability, just the ability to visualise 2D data as a surface in 3D.

The code would end up allowing you to just call xr.Dataarray.plot.surface() to create something like this example from here (code here):

Example surface plot

Obviously xarray would be used to automatically set the axes labels and title and so on.

As far as I can tell it wouldn't be too difficult to do, it would just be implemented as another 2D plotting method the same way as the Dataarray.plot.imshow(), Dataarray.plot.contour() etc methods currently are. It would require the imports

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

but these would only need to be imported if this type of plot was chosen.

I would be interested in trying to add this myself, but I've never contributed to an open-source project before. Is this a reasonable thing for me to try? Can anyone see any immediate difficulties with this? Would I just need to have a go and then submit a pull request?

@shoyer
Copy link
Member

shoyer commented Jun 18, 2018

Hi Tom,

Sure, this seems like a pretty reasonable feature addition to me. One thing to consider is that this will need to be a bit of a special case compared to other 2D plots in xarray, because the axes are now in 3D. For example, I'm pretty sure faceting wouldn't work. Otherwise it would be best to make methods as consistent with other plotting methods as possible.

We have a contributor guide that's probably worth a look over.

Feel free to post a "Work in progress" pull request when you're ready for feedback.

Cheers,
Stephan

@stale
Copy link

stale bot commented May 18, 2020

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity

If this issue remains relevant, please comment here or remove the stale label; otherwise it will be marked as closed automatically

@stale stale bot added the stale label May 18, 2020
@stale stale bot closed this as completed Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants