Skip to content

Contour plots with no colorscale should go in the legend #2880

Closed
@alexcjohnson

Description

@alexcjohnson

... 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
screen shot 2018-08-07 at 2 33 08 pm

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

cc @etpinard @phxnsharp

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething brokenfeaturesomething new

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions