岭线图2
岭线图又称山脉图,可用来观察一个连续变量在不同组中的分布情况。
安装并载入R包。
install.packages("ggridges")
library(ggridges)
library(ggplot2) # 需安装install.packages("ggplot2")
ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
geom_density_ridges(color = "grey", stat = "binline", bins = 20) +
theme_bw()
2023-02-22 16:59