如何在geom_vridgeline(ggridges,ggplot)中绘制分位数线

时间:2018-12-20 20:51:38

标签: r ggplot2 ggridges

我能够使用ggridges建立水平密度脊线图,并通过以下代码进一步添加分位数线:

#Horizontal density ridges analysis
ggplot(delaware, aes(x = b1_b3, y = LLRange)) + 
  geom_density_ridges(rel_min_height = 0.01, quantile_lines = TRUE, quantiles = 2) +
  theme_ridges(grid = FALSE)

水平密度脊图像:

horizontal density ridge with quantile

然后我使用以下简单代码(geom_vridgeline)将相同的分析转换为显示垂直脊:

ggplot(delaware, 
  aes(x = LLRange, y = b1_b3, width = ..density.., color = LLRange, fill = LLRange)) +
  geom_vridgeline(stat = "ydensity", trim = FALSE, alpha = 0.5, scale = 1) +
  theme_ridges(grid = FALSE) + 
  scale_y_continuous(limits = c(0.5, 2))

vertical ridge line plot

quantile_lines = TRUE, quantiles = 2添加到geom_vridgeline不起作用。我看到它不支持quantile_lines。如何绘制分位数线?

0 个答案:

没有答案