Skip to content
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

histogram colored bars #1984

Closed
chriddyp opened this issue Sep 4, 2017 · 5 comments
Closed

histogram colored bars #1984

chriddyp opened this issue Sep 4, 2017 · 5 comments

Comments

@chriddyp
Copy link
Member

chriddyp commented Sep 4, 2017

as reported in https://community.plot.ly/t/coloring-selected-range-in-histogram/5619/1

it looks like marker.color is documented in the schema
image

but i couldn't get it to work
image

@etpinard
Copy link
Contributor

etpinard commented Sep 5, 2017

Here's one that works: http://rickyreusser.com/plotly-mock-viewer/#histogram_colorscale

But really, how is marker.color supposed to work for histogram where x.length in general doesn't match marker.color.length?

@alexcjohnson
Copy link
Collaborator

right, we had already discussed removing histogram colorscale functionality, at least as implemented now - see #420 (comment) and #1500 - because it only works accidentally and depends on you explicitly making the correspondence between bins and color values. But I could certainly see supporting a histogram-specific colorscale functionality, where probably you would specify it similarly to #histogram_colorscale but instead of a color array you'd connect the color to either the x or the y values.

@chriddyp the issue with doing it the way you tried is, as @etpinard alluded, the values you want to color don't match up with the values you're binning... so it's redundant (and ambiguous - what happens when two values that get binned together have different colors?) and also generally you'd want to color by either the bin value or the bin height rather than the pre-binned values.

@chriddyp
Copy link
Member Author

chriddyp commented Sep 5, 2017

but instead of a color array you'd connect the color to either the x or the y values.

Yeah, that sounds right. For more context, they would likely be using this to make these types of interactions (currently made with a bar chart):
histogram-colored-bar

@jonmmease
Copy link
Contributor

If marker.color is specified as an array of numbers then perhaps an aggregate function from the transform framework (count, sum, mean, etc.) could be specified (e.g. marker.coloragg) to be applied prior to mapping the result to a final color using marker.colorscale.

In this case, color=y with coloragg='count' would be equivalent to coloring by bar height and color=y with coloragg='mean' would be equivalent to coloring by bar position. But lots of other interesting possibilities would be available as well, like color=z with coloragg='median' to color by the median of some other data array z.

@chriddyp @alexcjohnson @etpinard

@gvwilson
Copy link
Contributor

Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson

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

No branches or pull requests

5 participants