fslaborg / fslaborg/FsLab

HexBin plot

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Difficulty: Advanced FsLab Hackathon 2023 Status: Available
Dominant language
F#
Stars
35
Forks
3
PR merge metrics
No merged PRs in 30d

Description

### Description

Hexagonal Binning is a method for visualizing bivariate distributions especially suited to visualize the distribution of large two-dimensional data sets [1, 2]

Hexagonal binning plots density, rather than points. Points are binned into gridded hexagons and distribution (the number of points per hexagon) is displayed using either the color or the area of the hexagons. This technique was first described in 1987 [3].

The underlying idea is as follows: an area containing the data set is tessellated [4] with regular hexagons [5]. The number/proportion of points falling in each cell is counted and mapped to a colormap.

### References

- [1] https://datavizproject.com/data-type/hexagonal-binning/
- [2] https://www.meccanismocomplesso.org/en/hexagonal-binning-a-new-method-of-visualization-for-data-analysis/ (this article contains further relevant references)
- [3] https://www.jstor.org/stable/pdf/2289444.pdf?refreqid=excelsior%3A00ebdad05e0a8714c3af18157eb67dfe&ab_segments=&origin=&initiator=&acceptTC=1
- [4] https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons
- [5] https://www.omnicalculator.com/math/hexagon#how-many-sides-does-a-hexagon-have-exploring-the-6-sided-shape

### Pointers

- Ideally, you start prototyping in a scripting or notebook environment where you can iterate fast
- The general process of creating a hexbin plot could look like this:
- select area to tesselate
- implement hexagonal tesselation and calculate hexagon positions
- bin existing data points into the hexagons (by their 2d position)
- create a plot containing the hexagons coloured according to the amount of points contained
- You most likely need to use and/or implement functions from both [FSharp.Stats](https://github.com/fslaborg/FSharp.Stats) **and** [Plotly.NET](https://github.com/plotly/Plotly.NET).
- The resulting top-level chart function is ideally implemented as an extension method in this repository to prevent Plotly.NET from receiving a FSharp.Stats dependency

Hints (click to expand if you need additional pointers)

- the matplotlib docs on hexbin go a bit into detail how they create the hexagonal grid: https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hexbin.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.