plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.28k stars 2.55k forks source link

Feature Request: Mapbox Density Heatmap Aggregation Option #2630

Closed phaabe closed 4 years ago

phaabe commented 4 years ago

Hi, I am wondering how data is aggregated in density map and this may turn into a feature request. As data can be aggregated in time, here in a density map it is aggregated in space. Meaning: When I have 3 points on a map and I zoom out they will be merged to one point -- they are aggregated. But which value should be taken here?

As for time-wise aggregation it depends on the application and I believe it makes sense to offer options here. Looking at this example I am not quite following how aggregation works. When I zoom into Greece I see a lot of tiny values being purple and showing values around 5 (hovering shows values). And when I zoom out it is turning more and more yellow which represents values around 9. But hovering still shows values around 5 again. How can that be explained? And how about adding this option?

Thanks

nicolaskruchten commented 4 years ago

The actual logic used to draw the map comes from Mapbox GL so probably the best answer to your question would be to check out their documentation: https://docs.mapbox.com/help/tutorials/make-a-heatmap-with-mapbox-gl-js/

nicolaskruchten commented 4 years ago

Also this: https://blog.mapbox.com/introducing-heatmaps-in-mapbox-gl-js-71355ada9e6c

Basically the heatmap here isn't aggregating values, it's representing a weighted density. When you hover, you see the data for the individual underlying points.

phaabe commented 4 years ago

Thanks for the answer!

The key phrase from the article is:

we draw the kernel (which looks like a blurred circle) into an offscreen half-float texture with additive blending (so that values are summed together when kernels overlap)

I will ask in their repository why they took this design decision :)