在R中将图与拼布结合在一起:面板之间的间距不一致,在两级修补图中 我正在尝试使用R中的拼布组合几个地块,但是我正在遇到一个问题,而面板之间的间距不一致。第一组图是用双SP绘制的...

问题描述 投票:0回答:1

在面板之间用双间距绘制第一组曲线(PA),而其他组的图(PB和PC)则以单个间距为单位,在最终布局中引起视觉上的不一致。
我试图与plot_spacer()
添加一个空间

但是,当使用更多图表时,这会导致更大的问题,我的数据集约为20个图。 This is an example with mpg data, look at the width of each one of the plots, it is supossed to be the same.有人知道我如何解决这个问题?任何帮助将不胜感激!

提前感谢

您可能会考虑使用

wrap_plots

而不是

|

+

来组合图。这也将通过标签级别解决问题:

library(ggplot2) library(patchwork) # Combined final plot pfail <- list( list(p1, p2), list(p3, p4), list(p5, p6) ) |> lapply(\(x) { x |> wrap_plots() + plot_layout( axis_titles = "collect", tag_level = "new" ) }) |> wrap_plots(nrow = 1) pfail <- pfail + plot_annotation( tag_levels = c("I", "a"), tag_sep = ".", tag_suffix = ":" ) + plot_layout(guides = "collect") pfail
r ggplot2 plot patchwork
1个回答
0
投票

    

© www.soinside.com 2019 - 2025. All rights reserved.