Is it possible to define default plots for xarrays/ xarray dataarrays?
cwerner opened this issue · 11 comments
Hi.
I'd like to specify one or two default visualizations for an intake_xarray set. However, I cannot find any info how to specify:
- a z-dimension I need to select
- a datavariable
Is this possible?
Currently, I use this:
metadata:
plots:
a_plot_name:
kind: 'image'
x: 'lon'
y: 'lat'
rasterize: True
Yes, I believe you can do exactly what you would like. The set of parameters to put in the plotting block would be the same as whatever you pass to source.plot
(or .hvplot
), so I would start by looking at the hvplot gallery for things that are similar for what you are after.
Thanks.
I‘m just puzzled how I’d specify a certain data array and select a certain level (a dimension) from the dataset to be plotted? Basically, how to specify a set of xarray sel statements before plotting...
@philippjfr would know which parameters to pass.
a z-dimension I need to select
I don't think you can currently select on a z-dimension (or any other dimensions), but we should definitely allow that so an issue would be appreciated. Currently you'll just get a widget to select along that dimensions.
a datavariable
To select a data variable you specify a z
value.
Thanks @philippjfr . I’ll experiment a bit more. In my case I do have geographic soil data that also has a layer dimension and about 20 data variables. I want to plot one datavariable and the top layer to give users an impression what’s contained in the resource...
C
z: xr variable name
works for me, see https://github.com/aaronspring/remote_climate_data/blob/a43f5e7e4f7193caeb0633d40cca2ed8127bca30/atmosphere.yaml#L5-L23
Hi @aaronspring
Thanks for the reference. I currently have this working like in your example, but my original idea seems not possible. Originally, I wanted to plot a simple 2d plot without selectors...
Consider this xarray dims: (lev, lat, lon)
and say 2 data variables TOTC
, TOTN
that follow these dims. How do I define a plot for TOTC
and the surface soil layer (lev=1
)? I'd have to perform a select over lev
in the plot definition but don't see how?
Cheers,
C
No idea. I would also like to know this. This is the question of subselecting the data before plotting.
you could try groupby: lev
and then lev
can be selected by hand, likely lev=1
is the default
I'm not opposed to adding sel and isel options to hvplot at least when loading from a yaml spec but these options are definitely not exposed right now.
See also holoviz/hvplot#505 (comment) and discussion around it