cf-xarray
cf-xarray copied to clipboard
add Dataset plot accessor.
to wrap _DatasetPlotMethods
.
This should be easy → follow what is done with _CFPlotMethods
@dcherian Where does _DatasetPlotMethods
exist? I can't find it in this repository's code. And I only see one reference to _CFPlotMethods
-- https://github.com/xarray-contrib/cf-xarray/blob/19d80cf48bf99e541f084f97c5ed84b83332d0bd/cf_xarray/accessor.py#L482
Are these upstream in Xarray?
I may have changed design since this was written. I think now we just need to modify _CFPlotMethods
appropriately to work.
We want the following to work:
import cf_xarray
import xarray as xr
ds = xr.tutorial.load_dataset("air_temperature").isel(time=slice(2))
ds.air.attrs["standard_name"] = "air_temperature"
ds.plot.scatter(x="air", y="lat") # works
ds.cf.plot.scatter(x="air_temperature", y="latitude") # doesn't work
https://github.com/xarray-contrib/cf-xarray/blob/19d80cf48bf99e541f084f97c5ed84b83332d0bd/cf_xarray/accessor.py#L624
We should add the _get_standard_name
mapper to the above dictionary. I think that might be all that's needed to get scatter to work.
_get_standard_name
I'm a little iffy on using the dict.fromkeys
method with more than one value. Would it look something like:
key_mappers=dict.fromkeys(self._keys, (_get_axis_coord_single, _get_standard_name)),
?
Yes