【问题标题】:Lines overlapping in R with ggridgesR中与ggridges重叠的线
【发布时间】:2020-02-18 02:42:48
【问题描述】:

我在 R 中使用 ggridges 来可视化我的数据。但是很多行是重叠的,难以阅读。

我的代码是:

ggplot(task1, aes(x = ibu, y = style, fill = style)) +
  geom_density_ridges(alpha=1) +
  theme_ridges() + 
  theme(legend.position = "none")

我应该改变什么来使这个可视化更具可读性?

【问题讨论】:

    标签: r ggplot2 ridgeline-plot ggridges


    【解决方案1】:

    您可以使用scale 参数来调整整体高度缩放。只需将其设置为产生您喜欢的结果的数字即可。

    library(ggplot2)
    library(ggridges)
    #> 
    #> Attaching package: 'ggridges'
    #> The following object is masked from 'package:ggplot2':
    #> 
    #>     scale_discrete_manual
    
    ggplot(iris, aes(x = Sepal.Length, y = Species, fill = Species)) +
      geom_density_ridges()
    #> Picking joint bandwidth of 0.181
    

    ggplot(iris, aes(x = Sepal.Length, y = Species, fill = Species)) +
      geom_density_ridges(scale = 0.5)
    #> Picking joint bandwidth of 0.181
    

    reprex package (v0.3.0) 于 2019 年 11 月 3 日创建

    【讨论】:

      猜你喜欢
      • 2021-08-12
      • 2020-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多