R ggplot2中子地块之间的大小和间距

R ggplot2中子地块之间的大小和间距,r,ggplot2,subplot,R,Ggplot2,Subplot,我有一个子地块如下 mydata <- data.frame(side1=rep(LETTERS[1:3],3,each=9),side2=rep(LETTERS[1:3],9,each=3),widget=rep(c("X","Y","Z"),9*3),size=rep(1/3,9*3),strength=runif(27,-1,1)) ggplot(mydata, aes(x="",y = size, fill = strength, width = widget)) + geom_

我有一个子地块如下

mydata <- data.frame(side1=rep(LETTERS[1:3],3,each=9),side2=rep(LETTERS[1:3],9,each=3),widget=rep(c("X","Y","Z"),9*3),size=rep(1/3,9*3),strength=runif(27,-1,1))

ggplot(mydata, aes(x="",y = size, fill = strength, width = widget)) +
geom_bar(width = 1) + 
facet_grid(side1 ~ side2) +
scale_x_discrete("",breaks=NULL) + 
coord_polar("y") + scale_fill_gradient2() +
scale_y_continuous("",breaks=NULL)+
theme(panel.grid=element_blank(),panel.border=element_blank())

mydata要减少子地块之间的空间,请使用
theme()中的
panel.margin=

library(grid)    
+theme(panel.margin=unit(0,"cm"))
要设置
unit()
您应该使用库
网格


每个子地块的大小取决于整个地块的大小。您可以使用
ggsave()
函数设置整个绘图的大小,以某些格式(pdf、jpg)保存绘图,并设置整个绘图的
width=
height=

要减少子绘图之间的空间,请使用
面板。例如,在
主题()中使用
margin=

library(grid)    
+theme(panel.margin=unit(0,"cm"))
要设置
unit()
您应该使用库
网格


每个子地块的大小取决于整个地块的大小。您可以使用
ggsave()
函数设置整个绘图的大小,以某些格式(pdf、jpg)保存绘图,并设置整个绘图的
width=
height=

@user702846更新了我的answer@user702846更新了我的答案