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

add scatter plot method to dataset #470

Closed
clarkfitzg opened this issue Jul 13, 2015 · 5 comments · Fixed by #2277
Closed

add scatter plot method to dataset #470

clarkfitzg opened this issue Jul 13, 2015 · 5 comments · Fixed by #2277

Comments

@clarkfitzg
Copy link
Member

Follow up on original plotting

@barronh
Copy link
Contributor

barronh commented May 25, 2017

+1

Especially useful when using unstructured spatial datasets like observation stations.

import xarray as xr
nstations = 9
data = np.random.random(size = nstations)
longitude = np.random.random(size = nstations) + -90
latitude = np.random.random(size = nstations) + 40
da = xr.DataArray(np.random.random(nstations ), dims = ['station'], coords = dict(longitude = ('station', longitude), latitude = ('station', latitude))
da.scatter(x = 'longitude', y = 'latitude')

@darothen
Copy link

This certainly could be useful, but since this is essentially plotting a vector of data, why not just drop into pandas?

df = da.to_dataframe()
# Could reset coordinates if you really wanted
# df = df.reset_index()
df.plot.scatter('longitude', 'latitude', c=da.name)

Patching in this rough functionality into the plotting module should be really straightforward, maybe @jhamman has some tips?

@pwolfram
Copy link
Contributor

I agree this could be helpful... is there any interest in reviving this stale issue?

@aidanheerdegen
Copy link
Contributor

In the absence of a dedicated method, it is possible to obtain a scatterplot with the keyword options to plot.line():

rho_so_remap.plot.line(marker='o',linewidth=0.)

unknown

@zxdawn
Copy link

zxdawn commented Feb 6, 2022

@aidanheerdegen Thanks for the code. I suppose it's better to mention this method for DataArray in User Guide. @dcherian
Should I create a PR for example like this?

air = xr.tutorial.open_dataset("air_temperature")['air']

air.isel(lon=10, lat=[19, 21, 22]).plot.line(x="time", marker='o',linewidth=0.,markersize=1)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants