Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.2k views
in Technique[技术] by (71.8m points)

r - Margins between plots in grid.arrange

I dont seem to be able to find a solution as to how to increase the space between two plots with grid.arrange. I find no clue as to how to proceed. I dont want to change the size of the plots or anything like that.

grid.arrange(plot1, plot2, ncol=2)

(The stuff below was added later):

This is the code that I have:

x11()

cs <- grid.arrange(arrangeGrob(b, a, ncol=2, top = textGrob(
                    "B", vjust = 0.5, hjust = 19.5, gp = gpar(
                     fontface = "bold", cex = 1.5)),
                     left = textGrob(~ Delta * "SCR (p - d)" ~ mu * 'S', 
                     gp=gpar(fontsize=18), rot = 90, vjust = 1)))
soc_sph <- grid.arrange(arrangeGrob(p, g, ncol=2, top = textGrob(
                     "A", vjust = 0.5, hjust = 19.5, gp = gpar(
                     fontface = "bold", cex = 1.5)),
                     left = textGrob(~ Delta * "SCR (p - d)" ~ mu * 'S', 
                     gp=gpar(fontsize=18), rot = 90, vjust = 1)))

grid.arrange(soc_sph, cs, ncol=2)

So it is in this last grid.arrange, the space between soc_sph and cs that is to be increased.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

the standard way is to change the plot margins,

pl = replicate(3, ggplot(), FALSE)
grid.arrange(grobs = pl)  # default settings

enter image description here

margin = theme(plot.margin = unit(c(2,2,2,2), "cm"))
grid.arrange(grobs = lapply(pl, "+", margin))

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...