Skip to content

Automatically color individual groupby child traces #1823

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
rreusser opened this issue Jun 27, 2017 · 4 comments
Closed

Automatically color individual groupby child traces #1823

rreusser opened this issue Jun 27, 2017 · 4 comments
Labels
feature something new

Comments

@rreusser
Copy link
Contributor

@jackparmer points out that when you add a groupby, only the legend changes, which isn't particularly helpful. Is there some way to work it in so that child traces don't simply inherit the same color and need to be manually styled to be meaningful?

Otherwise this may be strictly a workspace issue, but it seems that if there's some way to accomplish this in plotly.js, that would be preferable.

It isn't entirely straightforward since they do inherit the parent styles, which is a single color. Perhaps this could be accomplished with groupby populating the style field with unique colors for each child trace. It's ugly to need to populate all the group style fields, but unless there's a better way to override the default color, then I'm not sure the best path.

@rreusser
Copy link
Contributor Author

Okay, going to try to PR this to vary colors for each expanded trace under the assertion that plotly.js should handle this differently. Second opinions welcome though, @alexcjohnson @etpinard.

@rreusser
Copy link
Contributor Author

I understand this issue better after digging a bit. The problem is that supplyTraceDefaults is run twice. Once on the input and then again out the expanded traces.

On the first pass, the default color is applied.
On the second pass, unique colors are applied to each expanded trace, but because the default color was already applied, it has no effect.

Is there any way to clear the color for the second pass? Or to cause the defaultColor to definitely be applied on the second pass in any general sort of way?

@rreusser
Copy link
Contributor Author

rreusser commented Jun 28, 2017

Okay, thinking through this over and over, and I'm struggling. The necessary behaviors:

  1. if no color is specified, each group should get an individual color. This would happen for free, but we need some hack to make supplyDefaults work. I think that hack is a flag that denotes whether a default color was applied and then module.clearDefaultColors so that the second pass just works.
  2. if a trace level color (e.g. line.color) is specified, it should just work like it does now. There's a little muddiness about whether it still splits colors. I think if you specify a color, you get the color. The only catch is that props can't be cleared in the workspace so that you'd have to delete and recreate the trace to unset it (unless I'm mistaken), but that's a separate UX issue.

I still think this seems more like a plotly.js issue than a workspace issue, but of course the nuclear alternative is to shift the burden to the workspace and just construct styles manually. That will cause the clear group styles button not to work very well though since it will reset everything to a non-default state.

@etpinard
Copy link
Contributor

done in #1830

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

2 participants