【发布时间】:2019-01-04 03:11:39
【问题描述】:
让我们从 docs 的示例中获取 ggplot2 小提琴图的数据集,
> ToothGrowth$dose <- as.factor(ToothGrowth$dose)
> head(ToothGrowth)
len supp dose
1 4.2 VC 0.5
2 11.5 VC 0.5
3 7.3 VC 0.5
4 5.8 VC 0.5
5 6.4 VC 0.5
6 10.0 VC 0.5
如果我们绘制图表,
library(ggplot2)
# Basic violin plot
p <- ggplot(ToothGrowth, aes(x=dose, y=len)) +
geom_violin()
p
# Rotate the violin plot
p + coord_flip()
# Set trim argument to FALSE
ggplot(ToothGrowth, aes(x=dose, y=len)) +
geom_violin(trim=FALSE)
我们得到了这个graph。
如何显示峰值的数值,即 Y 轴上密度最高的点?
【问题讨论】:
标签: r ggplot2 violin-plot