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

Removing the legend from NdOverlay also removes the colors #6224

Open BMM3 opened 2 months ago

BMM3 commented 2 months ago

ALL software version info

holoviews: 1.18.3

Description of expected behavior and the observed behavior

I am creating a layout with multiple NdOverlays plots where each NdOverlay shows multiple colored graphs. (see example below) When I use the option “show_legends=0” to only show 1 legend in the full layout, I see that all the plots that don’t have a legend anymore also don’t have any different colors anymore.

Notice: when I just set the “show_legend” to false for all (except for 1) plot, I do get a normal plot.

Complete, minimal, self-contained example code that reproduces the issue

df = pd.DataFrame({'x': [1,2,3], 'y': [2,3,4],})
p1a = hv.Scatter(df, kdims='x', vdims=['y']).opts(color='red', size=8)
df = pd.DataFrame({'x': [1,2,3], 'y': [5,6,7],})
p2a = hv.Scatter(df, kdims='x', vdims=['y']).opts(color='green', size=8)
pa = hv.NdOverlay({'red':p1a, 'green':p2a}, 'plots').opts(legend_position='right')
df = pd.DataFrame({'x': [1,2,3], 'y': [1,1.5,2],})
p1b = hv.Scatter(df, kdims='x', vdims=['y']).opts(color='red', size=8)
df = pd.DataFrame({'x': [1,2,3], 'y': [3,4,5],})
p2b = hv.Scatter(df, kdims='x', vdims=['y']).opts(color='green', size=8)
pb = hv.NdOverlay({'red':p1b, 'green':p2b}, 'plots').opts(legend_position='right')
p = pa+pb
p.opts(show_legends=0)

Screenshots or screencasts of the bug in action

A plot with multiple legends: image

A plot with a single legend: image