I have two plots that I combine. arrangeGrob()
squeezes them so that the size of the new image is the same as one alone. How can I arrange them while preserving the ratio/size?
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
looks like
I have not found any parameter in ggplot()
or arrangeGrob()
that fixes the ratio of the input.
Edit: Additional complications arise from the definition of axis labels in arrangeGrob()
, i.e.
plot <- arrangeGrob(plot1, plot2, left="LHS label")
Then the new file will not automaticall shrink to the minimum height/width combination of plot1
and plot2
.
respect=TRUE
, that's all I needed. I wonder why it's not in the documentary. – Locative