holoviz / holoviews

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

NdOverlay legend fails #3647

Open Mossi8 opened 5 years ago

Mossi8 commented 5 years ago

When I try to make my own color legend with NdOverlay and I make a color list with more than 21 colors it fails and plots one point. However if I make a shorter list works just fine and makes the legend.

A similar thing occurs when I just make an NdOverlay plot with a dictionary with less than 21 points; the legend just appears automatically, which is nice. However, when I plot with NdOverlay a dictionary larger than 21 entries it fails and does not plot the legend.

I do not believe this was happening before.

Thank you so much for your time.

%opts Points [height=1000 width=1000 show_legend=True]

from bokeh.palettes import Viridis11,Magma11,BrBG10

color_list = Viridis11+Magma11+BrBG10 color_key = {k: c for k, c in zip(cl, color_list[:len(cl)])} legend = {c :hv.Points([0,0]).opts(style=dict(color=color_key[c])) for c in color_key} hv.NdOverlay(legend) image

%opts Points [height=1000 width=1000 show_legend=True]

from bokeh.palettes import Viridis11,Magma11,BrBG10

color_list = Viridis11+Magma11 color_key = {k: c for k, c in zip(cl, color_list[:len(cl)])} legend = {c :hv.Points([0,0]).opts(style=dict(color=color_key[c])) for c in color_key} hv.NdOverlay(legend)

image

jbednar commented 5 years ago

That does sound like an issue. Note that if you need a long list of categorical colors, you could consider using one of the 256-color categorical colormaps available in Colorcet, which will be more easily distinguishable than an arbitrary set of colors like that.

Mossi8 commented 5 years ago

Yes, I was just playing a bit with different color palettes. The 256 colormaps were giving the same behaviour, though.

Thank you!

philippjfr commented 5 years ago

The problem here is the legend_limit option, the behavior is really an optimization and by raising the limit you could fix this. Until bokeh supports multi-column legends I've always considered legends with 20+ items kind of useless.

jbednar commented 5 years ago

Ah, good point. Should this be a warning, which people could avoid by explicitly turning off legends? That way they would realize that there is something they need to choose (either raising the limit or turning them off). But then if people really do want this behavior and don't want a warning, they couldn't have that. I guess then we could add an option to suppress the warning, but that's a lot of complexity. Not sure what I'd vote for...

philippjfr commented 5 years ago

Yes, a warning seems appropriate.