How to adjust facet size manually

前端 未结 3 1375
-上瘾入骨i
-上瘾入骨i 2020-12-13 14:29

I have a faceted plot with very diverse data. So some facets have only 1 x value, but some others have 13 x values. I know there is the parameter <

3条回答
  •  既然无缘
    2020-12-13 14:52

    Ah yes very sad that functionality to set widths and heights in facet_grid is gone.

    Another possible workaround without ggplotGrob is to set the text angle in theme(strip.text.x=element_text(angle...)) and facet text wrapping in facet_grid(... labeller=label_wrap_gen(width...)), e.g.

    ggplot(df, aes(x,y,color=i)) +
      geom_point() +
      facet_grid(labely~labelx, scales='free_x', space='free_x', labeller=label_wrap_gen(width = 10, multi_line = TRUE)) +
      theme(strip.text.x=element_text(angle=90, hjust=0.5, vjust=0.5))
    

提交回复
热议问题