【发布时间】:2014-09-28 19:30:14
【问题描述】:
我有两个要合并的情节。 arrangeGrob() 挤压它们,使新图像的大小与单独的相同。如何在保持比例/大小的同时排列它们?
require(ggplot2)
require(gridExtra)
dat <- read.csv("http://www.ats.ucla.edu/stat/data/fish.csv")
frqncy <- as.data.table(table(dat$child))#
frqncy$V1 <- as.numeric(frqncy$V1)
plot1 <- ggplot(frqncy, aes(x=V1, y= N)) +
geom_histogram(stat="identity", binwidth = 2.5)
plot2 <- ggplot(frqncy, aes(x=V1, y= N)) +
geom_density(stat="identity")
plot <- arrangeGrob(plot1, plot2)
Plot 看起来像
我在ggplot() 或arrangeGrob() 中没有找到任何固定输入比例的参数。
编辑:arrangeGrob() 中轴标签的定义会引起其他复杂情况,即
plot <- arrangeGrob(plot1, plot2, left="LHS label")
那么新文件不会自动收缩到plot1和plot2的最小高度/宽度组合。
【问题讨论】: