You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Contour plots with no colorscale should go in the legend #2880
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 contour traces the showlegend attribute, and have it default to true for both contours.type='constraint' and contours.coloring='none' traces, false otherwise.
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
Always give contour traces the showlegend attribute, and have it default to true for both contours.type='constraint' and contours.coloring='none' traces, false otherwise.
I agree, this should be the default behavior. But I think the contours.coloring: 'none' part qualifies as a backward incompatible change even though contours.coloring: 'none' traces never have colorbars. So I'd vote for making showlegend: false by default whenever contours.type !== 'constraint' in v1 and change to a smarter default in v2.
Make a way to display even contours with colorscale in the legend.
That would be cool. Would contours.showlegend: true | false be too confusing or legendmode: 'trace' | 'contours' be better?
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?
The legend entry could either just show the line (which has a single color),
Not if contours.coloring is set to 'lines'.
or perhaps for consistency we fill below either using the middle color or with a gradient showing the whole colorscale.
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 line style.That way contours.coloring: 'line' traces would have unfilled rectangles as legend items,
@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'.
Activity
etpinard commentedon Aug 7, 2018
I agree, this should be the default behavior. But I think the
contours.coloring: 'none'part qualifies as a backward incompatible change even thoughcontours.coloring: 'none'traces never have colorbars. So I'd vote for makingshowlegend: falseby default whenevercontours.type !== 'constraint'in v1 and change to a smarter default in v2.That would be cool. Would
contours.showlegend: true | falsebe too confusing orlegendmode: 'trace' | 'contours'be better?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
contours.coloringis set to'lines'.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
linestyle.That waycontours.coloring: 'line'traces would have unfilled rectangles as legend items,phxnsharp commentedon Aug 8, 2018
@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'.
alexcjohnson commentedon Aug 15, 2018
Moved this to #420 as it would be a breaking change. The rest of this issue is handled in #2891 so closing.