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

后端 未结 1 1804
滥情空心
滥情空心 2021-01-03 11:03

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:30

    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)
提交回复
热议问题