Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying multiple legends in a single trace in Plotly

So the docs pretty much make it look like displaying multiple legends for different items of the same trace (plotly.graph_objs.Scatter) isn't something that Plotly supports by default. You should rather keep adding new traces to Figure and each of these traces contains its own legend.

However, this seems cumbersome for my specific case. What I have is a graph in Plotly Dash where the user can search for different nodes & paths and so I am defining different colors according to the search and all of this within a single trace (by making use of colorscale & color from Scatter).

When a user searches for different nodes in the graph I am coloring them uniquely. I'd like to specifically show a legend for each of the different colors which highlight these nodes.

Is it possible to do this in a single trace?

like image 987
Bendemann Avatar asked Sep 18 '25 01:09

Bendemann


1 Answers

Currently this is not possible. There is no such example in the docs though there is an issue on this topic since a couple of years now.

like image 195
Bendemann Avatar answered Sep 20 '25 16:09

Bendemann