Would be awesome if we could add shapes to the legend
Yes, it would be doable to customize legend items with svg paths.
Good suggestion, but this is not a high priority I'm afraid.
I would also like to see this.
This needs to be added please 👍
^ Seconded!
Any update on this...?
I've got a workaround with code using bars at: https://dash-ts-highlight.herokuapp.com/

I just had the case to use this. Wanted to show a highlighted region in the legend so all the information related to visual elements is in one place.
I also have a few cases where this would be very nice. In my most recent case, I would like to show night time hours on a histogram of occurrences by hour in a day. (1) It would help explain the plot without external elements and (2) it would be nice to toggle on and off.
I think this feature would be a great addition; very helpful for showing/hiding plot overlays!
It's already been 5 years since this post. Is it being worked on or planned to? Would you accept pull requests that solve this?
To be clear about what people want here, it's the ability to add legend items corresponding to certain items in layout.shapes, right? Which would presumably allow those shapes to be toggled on or off by clicking the legend. (As opposed to inserting new custom shapes into existing legend entries, which seems to be how @etpinard interpreted this query originally)
This isn't on our roadmap, though if a company were interested in sponsoring it we'd be happy to talk https://plotly.com/consulting-and-oem/
But absolutely we'd be happy to accept and review a pull request. Before starting we should nail down the attributes to be created. I'm thinking these would be (within shapes/attributes):
showlegend (boolean)legendgroup (string) - so you can toggle multiple shapes togethervisible needs to add the option 'legendonly'If that's all we add, shapes will all show up at the bottom of the legend, unless they're put into the same legendgroup as an earlier trace. Hopefully that's OK for the first version, later we can think about some more flexible ordering options.
Anything I'm missing?
This issue has been tagged with NEEDS SPON$OR
A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort.
Sponsorship range: $10k-$15k
What Sponsorship includes:
Please include the link to this issue when contacting us to discuss.
Just came across this problem today and would love to see it as well :)
same here!^
For R as well too.
Up!
Would love to see that as well!
Most helpful comment
To be clear about what people want here, it's the ability to add legend items corresponding to certain items in
layout.shapes, right? Which would presumably allow those shapes to be toggled on or off by clicking the legend. (As opposed to inserting new custom shapes into existing legend entries, which seems to be how @etpinard interpreted this query originally)This isn't on our roadmap, though if a company were interested in sponsoring it we'd be happy to talk https://plotly.com/consulting-and-oem/
But absolutely we'd be happy to accept and review a pull request. Before starting we should nail down the attributes to be created. I'm thinking these would be (within
shapes/attributes):showlegend(boolean)legendgroup(string) - so you can toggle multiple shapes togethervisibleneeds to add the option'legendonly'If that's all we add, shapes will all show up at the bottom of the legend, unless they're put into the same
legendgroupas an earlier trace. Hopefully that's OK for the first version, later we can think about some more flexible ordering options.Anything I'm missing?