【问题标题】:Size and space between subplots in ggplot2ggplot2中子图之间的大小和空间
【发布时间】:2013-05-12 04:04:31
【问题描述】:

我有一个子图如下

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())

我想减少每个子图之间的空间以及它们的大小。因为我在制作 100x100 子图之后。因此,彼此靠近以及尺寸非常重要。

【问题讨论】:

    标签: r ggplot2 subplot


    【解决方案1】:

    要减少子图之间的空间,例如在theme() 中使用panel.margin=

    library(grid)    
    +theme(panel.margin=unit(0,"cm"))
    

    要设置unit(),你应该使用库grid

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

    【讨论】:

    • @user702846 更新了我的答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    • 2019-05-25
    • 1970-01-01
    相关资源
    最近更新 更多