-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
... and even contour plots with a colorscale might want to be in the legend instead of a colorbar.
Consider this plot with 3 overlaid contour traces: https://codepen.io/alexcjohnson/pen/oMazOJ?editors=0010

The blue constraint-type trace shows up in the legend, as it should.
But the red trace doesn't show up in the legend OR in a colorbar (@phxnsharp I'm curious, how did you get a colorbar to appear in this case? Did you make a fake colorscale like [[0, 'red'], [1, 'red']]? When coloring='none' we currently don't even allow a colorbar)
And the black-and-white trace, despite the fact that it does have a colorscale, the user may prefer to show it in the legend anyway, especially when the levels are already labeled on the plot itself, but also so that in plots like this with many overlaid traces you can use the legend to hide it. The legend entry could either just show the line (which has a single color), or perhaps for consistency we fill below either using the middle color or with a gradient showing the whole colorscale.
Finally, if we have a colorbar and a legend on the same plot, it would be great if there were a way to automatically ensure they don't overlap. This may be tricky to do in a backward-compatible way however. Multiple colorbars also overlap by default...
Applies to contourcarpet as well.
Proposal:
- Always give
contourtraces theshowlegendattribute, and have it default totruefor bothcontours.type='constraint'andcontours.coloring='none'traces,falseotherwise. - Make a way to display even contours with colorscale in the legend.
- Further discussion needed on if and how to automatically avoid legend/colorbar overlaps