holoviz-topics / examples

Visualization-focused examples of using HoloViz for specific topics
https://examples.holoviz.org
Creative Commons Attribution 4.0 International
82 stars 24 forks source link

Problem with ship_traffic legend #279

Open rsignell-usgs opened 1 year ago

rsignell-usgs commented 1 year ago

I'm guessing something changed with one of the packages, because when I run the interactive ship traffic cell, I get two legends. The first one is coming from the points datashader object but I can't figure out how to turn it off! Help @jlstevens !

ship_traffic

jlstevens commented 1 year ago

I have noticed this and this is part of the work I am actively working on right now - hoping to get this fixed soon.

rsignell-usgs commented 1 year ago

Is there a workaround? I'd love to give a live demo tomorrow during my final presentation here at NATO CMRE in Italy, 11:00 Italy time.

jlstevens commented 1 year ago

I'll have a look this evening.

This legend is already generated with a workaround so I don't expect it will be hard to hide (or simply filter out) those annoying numbers (which is probably the correct thing to do tbh as the vessel types are supposed to be grouped into the named categories)

jlstevens commented 1 year ago

Here is the simple fix I've found so far:

tiles * labels * points.opts(show_legend=False) * legend.opts(xaxis='bare',yaxis='bare', title='')

Looks like points now gets an automatic legend which merges with the custom one.

jlstevens commented 1 year ago

@rsignell-usgs I've updated the deployment to fix the legend and which also includes some new hover functionality (WIP): https://ship-traffic.pyviz.demo.anaconda.com/ship_traffic

jbednar commented 1 year ago

I just had to discover a similar fix for the Census example. Seems like the automatic legend (which I totally don't remember us implementing!) needs a way to pass a mapping from category value (12) to category name (Tug). legend_mapping={12:"Tug", ...}?

rsignell-usgs commented 1 year ago

@jlstevens , awesome! Just in time for my live demo!!!!

jlstevens commented 1 year ago

I think that a mapping option would make sense!

When using categorical datashader operations in holoviews, I would hope we don't need the mapping as we would set the names explicitly.

jlstevens commented 1 year ago

@Hoxbro @jbednar I think the legend_mapping suggestion makes sense as an override.