joy plot是类似于多组分类的重叠在一起的密度图(density plot),其效果图如下图所示:

从这个图上可以明显看出来不同组之间的关系。在R中可以导入ggjoy包实现。
假如直接用ggplot2做density plot,会显得有点不够直观:
library(ggplot2)
data(diamonds)
g <- ggplot(diamonds) +
geom_density(aes(x = price, fill = color), color = NA, alpha=.35) +
labs(title="Density plot",
x="Price",
fill="Color")
g

用ggjoy实现joyplot:
library(ggjoy)
ggplot(diamonds, aes(x = price, y = color, fill = color)) +
geom_joy(scale = 4) +
scale_fill_cyclical(values = c("#FFAF60", "#81C0C0")) + theme_bw()

欢迎关注公众号!

网友评论