holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.66k stars 396 forks source link

NdOverlay of `subcoordinate_y` plot with wide DF vdim mapper should not sort the columns #6281

Closed droumis closed 3 weeks ago

droumis commented 3 weeks ago

version: holoviews 1.19.0rc3

NdOverlay sorts the curves and changes the ordering. I don't think this is expected behavior.

Also, the title should be suppressed unless specified at the overlay level, not taken from a single subplot.

Code ```python import numpy as np import pandas as pd import holoviews as hv import colorcet as cc hv.extension('bokeh') GROUP_EEG = 'EEG' N_CHANNELS_EEG = 31 N_SECONDS = 5 SAMPLING_RATE_EEG = 100 INIT_FREQ = 2 # Initial frequency in Hz FREQ_INC = 5 # Frequency increment AMPLITUDE_EEG = 1000 # Amplitude multiplier # Generate data total_samples_eeg = N_SECONDS * SAMPLING_RATE_EEG time_eeg = np.linspace(0, N_SECONDS, total_samples_eeg) def generate_eeg_data(index): return AMPLITUDE_EEG * np.sin(2 * np.pi * (INIT_FREQ + index * FREQ_INC) * time_eeg) eeg_channels = [str(i) for i in np.arange(N_CHANNELS_EEG)] eeg_data = np.array([generate_eeg_data(i) for i in np.arange(N_CHANNELS_EEG)]) eeg_df = pd.DataFrame(eeg_data.T, index=time_eeg, columns=eeg_channels) eeg_df.index.name = 'Time' # Create plot time_dim = hv.Dimension("Time", unit="s") curves = {} for col in eeg_df.columns: curve = hv.Curve(eeg_df[col], time_dim, hv.Dimension(col, label='Amplitude', unit='uV'), label=str(col)) curve = curve.opts(subcoordinate_y=True, tools=['xwheel_zoom', 'hover'], color='grey', ) curves['EEG', col] = curve curves_overlay = hv.NdOverlay(curves, ["Group", "Channel"]).opts( xlabel=time_dim.pprint_label, ylabel="Channel", show_legend=False, aspect=3, responsive=True, min_height=600, ) print(curves_overlay) curves_overlay ```

image

philippjfr commented 3 weeks ago

This is expected but not documented well, fix is to set sort=False on the NdOverlay:

hv.NdOverlay(curves, ["Group", "Channel"], sort=False)