Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the list of kdims of a holoviews Dataset

Tags:

holoviews

I have a tabular data set and it has multiple columns that might be the key dimension for some plots.

ds = hv.Dataset(data_df, kdims=['time', 'forecasttime', 'group'], vdims=['speed'])

I could initial use a curve plot:

ds.to(hv.Curve, kdims=['time'], vdims=['speed'])

This would provide timeseries curves with a selector widget on 'forecasttime', 'group'.

What I would like to achieve is to plot a curve that ignores the key dimenion 'forecasttime', 'group'. While I could certain achieve the samething by defining my Dataset object in a different way like the following:

ds = hv.Dataset(data_df, kdims=['time'], vdims=['speed'])
ds.to(hv.Curve, kdims=['time'], vdims=['speed'])

I was hoping that I could remove a key dimension from the kdims of ds after it is defined. What could I do?

I am new to holoviews. Perhaps I am not using holoviews's Dataset object the correct way. I would also appreciate any advice.

like image 690
huang Avatar asked Sep 14 '25 13:09

huang


1 Answers

You can easily ignore the additional dimensions by declaring the groupby keyword to be empty in the call to .to, e.g.

ds.to(hv.Curve, kdims=['time'], vdims=['speed'], groupby=[])

That said in the case of a Curve it is a bit weird to just ignore a dimension and you may end up with the curve zig-zagging across the plot. Since I don't know the structure of your data this may well be a valid thing to do though. If you instead want to overlay each Curve something like this might be what you want:

ds.to(hv.Curve, kdims=['time'], vdims=['speed'], groupby=['group']).overlay()

or written more simply:

ds.to(hv.Curve, 'time', 'speed', 'group').overlay()
like image 72
philippjfr Avatar answered Sep 17 '25 19:09

philippjfr