-2

我有cowplot的以下命令

require(cowplot);
tiff('./solution/AGM2.tiff', height = 18,width = 25, units = 'in',res = 60)

plot_grid(a28 + theme(axis.title.y = element_text(size =40),
                      axis.title.x=element_text(size =40),
                      axis.text.x=element_text(size =35),
                      axis.text.y=element_text(size =40),
                      title=element_text(size = 30),
                      legend.text=element_text(size = 30)),
          a33 + theme(axis.title.y = element_text(size =40),
                      axis.title.x=element_text(size =40),
                      axis.text.x=element_text(size =35),
                      axis.text.y=element_text(size =40),
                      title=element_text(size = 30),
                      legend.text=element_text(size = 30)),
          a61 + theme(axis.title.y = element_text(size =40),
                      axis.title.x=element_text(size =40),
                      axis.text.x=element_text(size =35),
                      axis.text.y=element_text(size =40),
                      title=element_text(size = 30),
                      legend.text=element_text(size = 30)),
          align = 'h', nrow=2, ncol = 2,hjust=0.5,vjust=0.5)

dev.off()

并得到下图

在此处输入图像描述

但我想把图表集中起来,特别是图表的第三个数字(MUFAt)。有人可以帮帮我吗?

4

2 回答 2

3

或者,

gridExtra::grid.arrange(ggplot(),ggplot(),ggplot(), 
                        layout_matrix=rbind(c(1,1,2,2),c(NA,3,3,NA)))

在此处输入图像描述

于 2017-03-09T22:15:58.317 回答
1

使用cowplot您不仅可以使用网格排列图形,还可以使用以下方法指定绘制每个单独图形的位置 draw_plot()

library(ggplot2)
library(cowplot)

# theme is repeated for each plot
my_theme <- theme(axis.title.y = element_text(size = 40),
                  axis.title.x = element_text(size = 40),
                  axis.text.x = element_text(size = 35),
                  axis.text.y = element_text(size = 40),
                  title = element_text(size = 30),
                  legend.text = element_text(size = 30))

# Dummy plots
g1 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) +
    geom_point(size = 5, show.legend = F) +
    my_theme

g2 <- ggplot(iris, aes(x = Petal.Width, y = Petal.Length, color = Species)) +
    geom_point(size = 5, show.legend = F) +
    my_theme

g3 <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color = Species)) +
    geom_smooth(show.legend = F) +
    my_theme


# tiff(height = 18,width = 25, units = 'in',res = 60)
png(height = 18,width = 25, units = 'in',res = 60)    

# Use x, y, height and width to customize each plot
ggdraw() +
    draw_plot(g1, x = 0, y = .5, height = .5, width = .5) +
    draw_plot(g2, x = .5, y = .5, height = .5, width = .5) +
    draw_plot(g3, x = .25, y = 0, height = .5, width = .5)

dev.off()

在此处输入图像描述

于 2017-03-09T10:50:32.767 回答