I have read about Beeswarm and Histogram plots. But I did not understand the difference. In a Histogram, if the bins number is increased then its intrepretation is changed. So how can a beeswarm plot help to understand the data?
They are quite similar but :
- Histograms results of aggregation into bins (loss of information due to aggregation: high-resolution point (2.324) is reduced to bins resolution [2,3])
- Beeswarm plot displays the exact value of points on the axis. It is a 1D-scatter plot.
However, if two points are very close to each other they will overlap if the point size is big enough. To avoid this, the beeswarm plot will slightly shift one point to the side so it does not overlap.
They will often look similar because the more points you have locally, the higher the probability of overlapping. Then, high-density areas will often result in "peaks" as in histograms.
The beeswarm plot is a more faithful representation
- Gap in the data: depending on the binning (both placement and size), the histogram may not represent it (as on point 1 in the figure).
- Min and max: Imagine values are limited at 5 but the histogram last bins continues to 6, it might give the impression that the max value of the variable is 6.
In both cases, you can see that beeswarm is a more faithful representation.
Because of this, it is not highly scalable (it has to represent every single point with no overlap). On the seaborn.swarplot function docs :
This function is similar to stripplot(), but the points are adjusted (only along the categorical axis) so that they don’t overlap. This gives a better representation of the distribution of values, but it does not scale well to large numbers of observations. This style of plot is sometimes called a “beeswarm”.