-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Contour plots with no colorscale should go in the legend #2880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I agree, this should be the default behavior. But I think the
That would be cool. Would We don't have a clean API for toggling contour levels, so I suspect click/double-clicking on those legend items wouldn't do anything in this iteration?
Not if
This one is tricky, if we want to cover all cases in one glyph, we could show a gradient corresponding to the colorscale in a rectangle and have its border follow the trace |
@alexcjohnson Yes, looks like my coder created a colorscale that is uniform, not knowing you could do anything else. Here is the typescript that creates the trace:
And to write it down for posterity, for our use case we do not require the colorscale mode combined with constraints at all. If it is available, we will make it available to our users but our defaults will always draw with contours.coloring set to 'none'. |
... 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']]
? Whencoloring='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:
contour
traces theshowlegend
attribute, and have it default totrue
for bothcontours.type='constraint'
andcontours.coloring='none'
traces,false
otherwise.cc @etpinard @phxnsharp
The text was updated successfully, but these errors were encountered: