在最直接的情况下,该拼布在配对两个面板方面做得很好,但它似乎也忽略了该子图的规范Legend Legend.box.box.spacing:

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

legend.box.spacing

这应该对齐两个数字的总宽度(使用enter image description herelibrary(ggplot2) p <- ggplot(mtcars, aes(wt, mpg)) p + geom_point(aes(colour = factor(cyl))) p1 <- p + geom_point(aes(colour = cyl))+ theme(legend.box.spacing = unit(20, 'pt')) p2 <- p + geom_point(aes(colour = cyl*100))+ theme(legend.box.spacing = unit(20, 'pt')) patchwork::wrap_plots(p1, p2, ncol = 1) ):

这次,传说和面板应根据其各自的设置定位。

free


收集的结果非常接近预期的结果。但这与各自的子图并不适合,这也不适当。 patchwork::wrap_plots(free(p1), free(p2), ncol = 1) enter image description here

因此,是否有一种方法可以使面板一致,同时确保每个子图的传奇是按照指定的固定在其自己的面板位置上的?
    

enter image description here一种实现所需结果的选择是将两个传说的理由设置为patchwork::wrap_plots(p1, p2, ncol = 1, guides = 'collect')

注:仅对于preprex,我在传奇框中添加了一个红色轮廓。 "left"

r ggplot2 patchwork
1个回答
0
投票


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