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更新了我的答案