Skip to content

Shared colorscales/colorbars aka coloraxes #3431

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

Closed
nicolaskruchten opened this issue Jan 12, 2019 · 14 comments
Closed

Shared colorscales/colorbars aka coloraxes #3431

nicolaskruchten opened this issue Jan 12, 2019 · 14 comments
Assignees
Labels
feature something new
Milestone

Comments

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Jan 12, 2019

Right now traces can share axes but not colorbars. It would be nice if they could, something like data[].coloraxis = "color1" with layout.coloraxis1 = { ... } and all bounds-computations could include the union of the data of the traces, etc

@etpinard etpinard added the feature something new label Jan 14, 2019
@nicolaskruchten nicolaskruchten changed the title Shared colorscales/colorbars Shared colorscales/colorbars aka coloraxes Feb 20, 2019
@etpinard etpinard self-assigned this Apr 4, 2019
@etpinard etpinard added this to the v1.48.0 milestone Apr 11, 2019
@etpinard
Copy link
Contributor

Quick question:

What should happen when traces that don't have the same colorbar visuals (e.g a heatmap and contour trace) share the same color axis?

In JSON form, this would be something like:

var data = [{
  type: 'heatmap',
  z: [[1,2,3], [2,3,3]],
  coloraxis: 'coloraxis'
}, {
  type: 'contour',
  z: [[2,3,1], [2,4,0]]
  coloraxis: 'coloraxis'
}]

var layout = {
  // e.g. some optional color-axis settings
  coloraxis: {
      colorscale: 'Viridis'
  }
}

then should we show two colorbars? A "combined" version (not sure how this would look like)? Maybe we could show a colorbar only if all traces have compatible color bar visuals? Or should color axes not have control over color bars at all? In other words, traces with the same coloraxis would share cmin / cmax / cmid and colorscale values - it would up the user to set showscale and the colorbar options accordingly in their trace(s).

@nicolaskruchten
Copy link
Contributor Author

Could we unify these color scales with a new attr like “discrete” or something? And then they could share

@nicolaskruchten
Copy link
Contributor Author

To be clearer: “discrete” would default based on the first trace that shares it, so contour-only would default to discrete and heatmap-only would not, and mixed would default to the first one but be overrideable

@alexcjohnson
Copy link
Collaborator

Contours with coloring: 'heatmap' would work just fine already - the colorbar would have lines on it for the contours I guess, which wouldn't match the heatmap, but that's probably OK. And contours with coloring: 'lines' (or 'none') I don't see any sense allowing to share a colorbar with heatmaps. So we're only talking about coloring: 'fills'. But since we have to exclude 'lines' and 'none' already, I'd argue for excluding 'fills' too - and only allow contours with coloring: 'heatmap' to share a scale with a heatmap - until we manage to do "discrete" right.

FWIW "discrete" itself has two variants that we need to be careful about. The version used in contour plots defines data values at the edges of each color - where the contour lines are. Much of the time heatmaps (and choropleths, scatter marker colors...) with discrete colors don't do that kind of mapping, they simply have discrete data and they map a single value to a single color. As far as the colorbar is concerned the main distinction is where the labels go: at the color boundaries vs midpoints. For the boundaries case we will need changes to trace rendering code, for the discrete data case we'll need changes to the colorbar rendering (and maybe trace rendering changes, if we want to also collapse multiple values onto one color)

@nicolaskruchten
Copy link
Contributor Author

nicolaskruchten commented Apr 18, 2019 via email

@alexcjohnson
Copy link
Collaborator

it probably looks like rejecting that coloraxis value from the latter trace, and giving it a separate colorscale and bar.

@nicolaskruchten
Copy link
Contributor Author

Hmm. Is there any xaxis/yaxis precedent for this kind of rejecting? If two incompatible traces declare coloraxis: "coloraxis1" would we force a second color axis to exist and map one trace onto it, despite the figure spec?

@alexcjohnson
Copy link
Collaborator

I feel like we do this in a bunch of situations, but one that comes to mind right now is scaleanchor, we'll ignore it if the referenced axis is the wrong type.

If we reject a coloraxis setting, that trace would have no coloraxis so it would behave like all traces do right now - the trace defines its own colorscale and colorbar.

@nicolaskruchten
Copy link
Contributor Author

nicolaskruchten commented Apr 18, 2019 via email

@etpinard
Copy link
Contributor

done in #3803

@nicolaskruchten
Copy link
Contributor Author

Did we end up doing anything to move from cmin/cmax to range? It doesn't look like it... would this be a good time to introduce this? I.e. when using coloraxis you have to use range instead of cmin/cmax ?

@etpinard
Copy link
Contributor

Was that a requirement?

@nicolaskruchten
Copy link
Contributor Author

No, it was just something I remember talking about: #3549 (comment)

@etpinard
Copy link
Contributor

Ok, well if someone has a strong opinion on

// the current
layout.coloraxis.cmin / layout.coloraxis.cmax

// vs
layout.coloraxis.crange 

// or vs
layout.coloraxis.range

you have about one week to speak up, before v1.48.0 is set for 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

No branches or pull requests

3 participants