Skip to content

Add plot() function #13

@mnlevy1981

Description

@mnlevy1981

@andersy005 or @mgrover1 -- I'm not totally sure where to start with this one, and maybe I'm overthinking it... but I'm getting caught up in how overloaded xr.DataArray.plot() is, so I don't really know what the desired output of this function is. Suppose we have

import xarray as xr
import xcollection as xc
ds = xr.tutorial.open_dataset('rasm')
dsa = xr.tutorial.open_dataset('air_temperature')
collection = xc.Collection({'rasm': ds, 'air_temp': dsa})

How would you call collection.plot() and what would you expect the plot to look like? I was initially picturing something like

def plot(var, *args, **kwargs):

but collection['rasm']['Tair'].plot(); is a histogram and you need collection['rasm']['Tair'].isel(time=___).plot(); to get a contour plot. So maybe

def plot(var, isel_dict={}, *args, **kwargs):

and we could call

collection.plot('Tair', {'time': ___})

but then what happens if multiple datasets in the collection contain var? Should we allow collections to containmatplotlib.figure.Figure objects? Then collection.plot() could return a collection of figures?

That seems like useful behavior for contour plots, but what about line plots? If I want to look at a time series or vertical profile at a given location (or maybe of a global mean), then should there be an option to return a single figure containing lines from all acceptable datasets? E.g. if I have a collection of 10 datasets, and five of them contain the variable Tair, then maybe I want to plot all five together with a legend containing the key for each dataset?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

⏸ Paused

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions