ggplot2: how to reduce space between narrow width bars, after coord_flip, and panel border

后端 未结 1 1500
半阙折子戏
半阙折子戏 2021-01-03 11:07

When you have flipped coordinates, how do you reduce the space between bars that are narrow and the panel border? Using the data frame df and the ggplot comman

1条回答
  •  一生所求
    2021-01-03 11:21

    I think I have found a solution. You can remove width from geom_bar and introduce theme(aspect.ratio = .2), then you can play with the ratio to find the desired width. And unlike coord_equal or coord_fixed is compatible with coord_flip.

    ggplot(df, aes(x = x, y = y)) + 
      geom_bar(stat = "identity") + 
      theme_tufte() + theme(aspect.ratio = .2) +
      coord_flip() +
      labs(x = "", y = "")
    

    0 讨论(0)
提交回复
热议问题