plotly / plotly.js

Open-source JavaScript charting library behind Plotly and Dash
https://plotly.com/javascript/
MIT License
16.87k stars 1.85k forks source link

Categorical colorscales #1747

Open alanocallaghan opened 7 years ago

alanocallaghan commented 7 years ago

Would it be possible to add the ability to use categorical (ie, String) values in a heatmap, mapped to a color scale?

This is currently possible only by mapping to numeric values and spoofing a colorscale and colorbar.

EG: https://i.stack.imgur.com/1MS66.png

Again apologies, in this case I realise this could require a radical overhaul of that trace

etpinard commented 7 years ago

Thanks for writing in. More generally, we should start thinking about adding categorical colorscales that could be applied not only to heatmap traces but to scatter bubble charts and choropleths to name a few.

In the meantime, here's a (somewhat hacky) workaround: https://codepen.io/etpinard/pen/GmbVZq?editors=0010

alanocallaghan commented 7 years ago

Cheers. If you have pointers on where to look I'd be glad to have a try, though my JS is not exactly the greatest

talgalili commented 7 years ago

+1 to this feature.

nicolaskruchten commented 6 years ago

Let's resurrect this guy :)

As a starting point, I propose a new flag somewhere that says "treat the values in the color array as discrete and generate a categorical colorscale" that way we could pass in either numbers or non-css strings and have a categorical colorscale/colorbar be generated.

nicolaskruchten commented 5 years ago

Additional thoughts on this from a conversation with @alexcjohnson when he was in Montreal: for categorical colorscales we ~should~ could not use the colorbar: we ~should~ could instead insert legend items like we do for pie traces.

bearmountainsolutions commented 5 years ago

has there been any progress on this?

nicolaskruchten commented 5 years ago

@etpinard can you propose something here plz?

talgalili commented 4 years ago

+1

amnfar commented 1 year ago

Do we have a solution now? I have also exhausted all my resources to plot cetagorical values in heatmap. Do we have categorical color scales for heatmaps ?