Reputation: 743
Is there an argument for adjusting the width to height ratio of the plotting area in forestplot()? I'd like to set the x-axis to be 2/3 of the height of the y-axis.
Thanks!
# Package
library(forestplot)
# Data
test_data <- data.frame(coef=c(1.59, 1.24),
low=c(1.4, 0.78),
high=c(1.8, 1.55),
varname=c("aa","bb"),
varexplan=c("A very long description A very long description","A very long description A very long description"))
test_data$varexplan <- as.character(test_data$varexplan)
test_data$varname <- as.character(test_data$varname)
# Prepare text
tabletext <- cbind(c(test_data$varname),
c(test_data$explan))
# Plot
forestplot(tabletext,
test_data$coef,
test_data$low,
test_data$high)
Upvotes: 0
Views: 2810
Reputation: 580
In case it helps somebody: package forestplot
does provide an option to set the graph width, aptly named graphwidth
, which requires an unit
argument: for instance,
forestplot(tabletext,
test_data$coef,
test_data$low,
test_data$high,
graphwidth = unit(5, "cm"))
which is probably a slightly more elegant option if you want to make the plot area proportions independent of the exporting function.
Upvotes: 1
Reputation: 72984
You could set the desired proportions when exporting the plot, e.g. with png()
. The plot will be saved into your working directory.
h <- 1080
png(height = h, width=2/3*h, res=300)
forestplot(tabletext,
test_data$coef,
test_data$low,
test_data$high)
dev.off()
Yielding
Upvotes: 0