#install.packages("ggbeeswarm")
set.seed(12345)
library(ggplot2)
## Warning: 程辑包'ggplot2'是用R版本4.2.3 来建造的
library(ggbeeswarm)
## Warning: 程辑包'ggbeeswarm'是用R版本4.2.3 来建造的
#compare to jitter
ggplot(iris,aes(Species, Sepal.Length)) + geom_jitter()

ggplot(iris,aes(Species, Sepal.Length)) + geom_quasirandom()

# Automatic dodging
sub_mpg <- mpg[mpg$class %in% c("midsize", "pickup", "suv"),]
ggplot(sub_mpg, aes(class, displ, color=factor(cyl))) + geom_quasirandom(dodge.width=1)

ggplot(iris,aes(Species, Sepal.Length)) + geom_beeswarm()

#https://github.com/eclarke/ggbeeswarm