代码之家  ›  专栏  ›  技术社区  ›  Myoch

使用position\u dodge preserve=single和facet\u wrap free\u x

  •  0
  • Myoch  · 技术社区  · 4 年前

    我正在创建一个箱线图,如下所示

    result = ggplot(
    data = data,
    aes(
      x = reorder(c, c_num),
      y = total,
      fill =paste(m, co),
      group = c
    )
    ) +
    geom_boxplot(lwd=0.8, position=position_dodge2(width=0.5, preserve="single")) +
    scale_x_discrete() +
    facet_wrap(m ~ co, nrow = 1, scale = "free_x") +
    

    但看起来

    preserve="single"
    

    当镶嵌面组中的条件数为1时无效。

    enter image description here

    有没有办法防止这种情况?

    0 回复  |  直到 4 年前
    推荐文章