This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R: save grid and base objects on same plot when making forest plots

I would like to plot grid objects and base R objects on the same png. The package I am using the meta package to make forest plots uses the grid graphics system.

I would like to use mfrow for this if possible, as it is what I am using elsewhere.

If I plot:

png("test.png",width=297,height=210,units="mm",res=300)
par(mfrow=c(2,2))
plot(1,1)
plot(1,1)
plot(1,1)
plot(1,1)
dev.off()

Everything works fine.

However if I plot:

library(meta)
m <- metaprop(4:1, c(10, 20, 30, 40))
png("test.png",width=297,height=210,units="mm",res=300)
par(mfrow=c(2,2))
plot(1,1)
forest(m,new=F)
plot(1,1)
forest(m,new=F)
dev.off()

Things aren't right as the forest plots try to take up the whole page rather than being restricted to their corners.

Thanks in advance for your help

r meta forest grid base r

I know this is a really late response, but you may want to check on StackOverlow as this is a CS intensive topic. Maybe a look at viewports might provide a lead.

0 answers

No answers yet.

Log in to answer this question.