I want to plot multiple items with a unique ID, and each ID should be assigned a random color in order to be able to distinguish the IDs in the plot. Ideally there would be a legend to show what ID is what color.
It is big data but when I do the plotting without assigning a color, it is super fast. As soon as I add “color=‘ID’” to the code it slows down 100x. Is there a better way to do this?
plot_column = pn.Column()
# Iterate through unique values of 'measurand' and create a separate plot for each
for measurand_value, group_df in selected_columns.groupby('measurand'):
group_df = group_df.sort_values(by='frequency', ascending=True) # Sort by 'frequency' in ascending order
dataset = hv.Dataset(group_df, kdims=['frequency', 'signal'], vdims=['ID'])
path_plot = hv.Path(dataset, label=f"'measurand': {measurand_value}").opts(
width=1280, height=600, **color='ID'**
)
plot_column.append(path_plot)