问题
I am making a forest plot in r using the forestplot package (see https://cran.r-project.org/web/packages/forestplot/forestplot.pdf).
I am satisfied with the look of the plot but the problem is that the resolution is not high enough. I have tried various things to increase the size of the plot but no matter what I do, the total plot area always remains the same (even if I can change the size of the text etc).
I'm including a couple of figures to illustrate my point. The second is simply created by setting the width and height parameters of the tiff function to double that of the first figure. Normally, this would cause the plot to be stretched over the entire area but that doesn't seem to be the case here but rather the second image only gets wide white margins.
And the second one:
The code is as follows:
library(rmeta)
tiff("/mypath", width=480*multifactor, height = 480*multifactor)
forestplot(tabletext,m,l,u,zero=0,is.summary=c(TRUE,FALSE,TRUE,rep(FALSE,(nrow(input)+1)),TRUE,TRUE,TRUE),clip=c(log(0.5),log(32)), xlog=TRUE,xlab="RR",xticks=c(0.5,1,2,4,8,16,32),col=meta.colors(box="royalblue",line="darkblue", summary="royalblue"))
dev.off()
And here is (slightly messy) reproducable example:
tabletext <-
structure(c("mock test", NA, "Site", "A", "B", "C", "D", "E",
"F", "G", "H", "I", "J", "K", NA, NA, "All", " ", " ", " ",
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" ", " ", " ", NA, NA, "Aff", "37", "140", "114", "34", "185",
"184", "26", "161", "90", "106", "191", NA, "RR", "1.61", NA,
NA, "Ctrl", "48", "152", "36", "80", "168", "191", "44", "86",
"15", "127", "74", NA, NA, NA, NA, NA, "RR", "7", "3", "4", "5",
"3", "4", "8", "2", "2", "3", "7", NA, NA, NA, " ", " ", " ",
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" ", "CI95%", "(1.31-1.97)", NA, NA, "P", "0.1", "0.1", "0.1",
"0.1", "0.1", "0.1", "0.1", "0.1", "0.1", "0.1", "0.1", NA, "P",
"0.02", " ", " ", " ", " ", " ", " ", " ", " ", " ",
" ", " ", " ", " ", " ", " ", " ", " "), .Dim = c(17L,
8L), .Dimnames = list(NULL, c("plot_col1", "plot_col2", "plot_col3",
"plot_col4", "plot_col5", "plot_col6", "plot_col7", "plot_col8"
)))
m <-
c(NA, NA, NA, 2.07944154167984, 1.6094379124341, 1.79175946922805,
1.94591014905531, 1.09861228866811, 1.79175946922805, 1.09861228866811,
2.07944154167984, 1.38629436111989, 0.693147180559945, 1.09861228866811,
NA, NA, 0.476234178996372)
l <-
c(NA, NA, NA, 1.79175946922805, 1.6094379124341, 1.79175946922805,
0.693147180559945, 1.09861228866811, 1.6094379124341, -Inf, -Inf,
1.38629436111989, 1.79175946922805, 0, NA, NA, 0.27002713721306
)
u <-
c(NA, NA, NA, 2.19722457733622, 2.19722457733622, 2.30258509299405,
2.07944154167984, 2.07944154167984, 2.19722457733622, 2.30258509299405,
2.07944154167984, 1.6094379124341, 2.30258509299405, 1.94591014905531,
NA, NA, 0.678033542749897)
Thank you for your help.
回答1:
I can't reproduce your example but did you try including 'res'?
tiff("test.tiff", width=480*multifactor, height = 480*multifactor, res=300)
forestplot(...)
dev.off()
来源:https://stackoverflow.com/questions/42580793/outputting-large-forestplot-with-r-forestplot-package