Closed droumis closed 3 weeks ago
I think this is what you want: hv.NdOverlay({col: hv.Curve(df, 'Date', hv.Dimension(col, label="Price", unit="$")).opts(tools=['hover'], subcoordinate_y=True) for col in df.columns}, 'Ticker')
.
Note that a tuple and a list do not do the same. E.g. a tuple is converted to a hv.Dimension
behind the scene, and a list contains a list of Dimensions (either as string or Dimensions).
Nice thanks! that works
Support hv.Dimension as vdim input for wide dataframe columns. For instance:
Traceback
```python --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[17], line 8 4 price_dim = hv.Dimension("Price", unit="$") # match the index name in the df 6 df = pd.read_csv('https://datasets.holoviz.org/stocks/v1/stocks.csv', parse_dates=['Date']).set_index('Date') ----> 8 hv.NdOverlay({col: hv.Curve(df, 'Date', (col, price_dim)).opts(tools=['hover'], subcoordinate_y=True) for col in df.columns}, 'Ticker') File ~/src/holoviews/holoviews/element/selection.py:25, in SelectionIndexExpr.__init__(self, *args, **kwargs) 24 def __init__(self, *args, **kwargs): ---> 25 super().__init__(*args, **kwargs) 26 self._index_skip = False File ~/src/holoviews/holoviews/element/chart.py:51, in Chart.__init__(self, data, kdims, vdims, **params) 50 def __init__(self, data, kdims=None, vdims=None, **params): ---> 51 params.update(process_dimensions(kdims, vdims)) 52 if len(params.get('kdims', [])) == self._max_kdim_count + 1: 53 self.param.warning('Chart elements should only be supplied a single kdim') File ~/src/holoviews/holoviews/core/dimension.py:117, in process_dimensions(kdims, vdims) 110 elif not isinstance(dims, list): 111 raise ValueError( 112 f"{group} argument expects a Dimension or list of dimensions, " 113 "specified as tuples, strings, dictionaries or Dimension " 114 f"instances, not a {type(dims).__name__} type. " 115 "Ensure you passed the data as the first argument." 116 ) --> 117 dimensions[group] = [asdim(d) for d in dims] 118 return dimensions File ~/src/holoviews/holoviews/core/dimension.py:60, in asdim(dimension) 50 def asdim(dimension): 51 """Convert the input to a Dimension. 52 53 Args: (...) 58 copy is performed if the input is already a Dimension. 59 """ ---> 60 return dimension if isinstance(dimension, Dimension) else Dimension(dimension) File ~/src/holoviews/holoviews/core/dimension.py:287, in Dimension.__init__(self, spec, **params) 284 values = [] 286 all_params['values'] = list(util.unique_array(values)) --> 287 super().__init__(**all_params) 288 if self.default is not None: 289 if self.values and self.default not in values: File ~/opt/miniconda3/envs/neuro-multi-chan/lib/python3.12/site-packages/param/parameterized.py:4187, in Parameterized.__init__(self, **params) 4185 if self.param.name.default == self.__class__.__name__: 4186 self.param._generate_name() -> 4187 refs, deps = self.param._setup_params(**params) 4188 object_count += 1 4190 self._param__private.initialized = True File ~/opt/miniconda3/envs/neuro-multi-chan/lib/python3.12/site-packages/param/parameterized.py:1685, in as_uninitialized.