How to shade an image with quantile color scale?
See original GitHub issueI’m trying to plot points with DataShader and want to render points with a quantile color scale. Would you please help me with it?
Data:
lon,lat,metric
30.771635, 108.353681, 34
30.765280, 108.351067, 85
Code:
import datashader as ds
import datashader.transfer_functions as tf
import colormap_select from datashader.colors
// shade image
cm = partial(colormap_select)
agg = cvs.points(df, lon, lat, ds.sum('metric'))
img = tf.shade(agg, cmap=cm(['green', 'yellow', 'red']), how='eq_hist')
My Goal [‘green’, ‘yellow’, ‘red’] represent a quantile scale of aggregation: [0, 33%, 66%, 100%] . In other words:
- green color: min -> 33% * max
- yellow color: 33% * max -> 66% * max
- red color: 66% * max -> max
Is there a method to achieve this color scale? furthermore, is there a way to flexibly define color stops ([0, 33%, 66%, 100%]) ?
Thank you.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
How to shade an image with quantile color scale? #566
I'm trying to plot points with DataShader and want to render points with a quantile color scale. Would you please help me with...
Read more >How to choose an interpolation for your color scale
I have a lowest value and a highest value. Just give the lowest value the brightest color and the highest value the darkest...
Read more >Add colours to the quantiles using ggplot - Stack Overflow
1 Answer 1 · Use unname(quantiles) for the breaks . Additionally I made use of scales::number for nice labels. · You could set...
Read more >Draws an image plot with a legend strip for the color scale...
Draws an image plot with a legend strip for the color scale based on either a regular grid or a grid of quadrilaterals....
Read more >"Coloring Maps" - roadtolarissa
This post describes several d3 quantitative scales - linear, quantize, quantile ... that the range is a color and has colorScale return lighter...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Your code above can be simplified to:
And presumably you are asking to get rid of the interpolation between green, yellow, and red that your code will produce?
If so, you can do that by constructing a colormap that avoids interpolation:
But personally, I like the interpolated one better. 😃
Glad you like our work! The example above is an adaptation and extension of my “census_gray_redhot1_eq_hist” example in http://datashader.org/topics/census.html. But that’s just one example buried deep in between a bunch of others, and I think colormap manipulations like that are worth addressing explicitly in the user manual so that more people realize what can be done.
We’re currently working on re-implementing datashader’s more advanced colormap features in Bokeh, and when we have that ready, we should include an overview in the manual of how to use colormapping to reveal your data flexibly and effectively, particularly in conjunction with the percentile interpretation of the results of
eq_hist
.