首页 > 解决方案 > Forestplot() 中绘图区域的宽度是否存在参数

问题描述

是否有调整 Forestplot() 中绘图区域的宽高比的参数?我想将 x 轴设置为 y 轴高度的 2/3。

谢谢!

# 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)

标签: rforestplot

解决方案


如果它对某人有帮助:包forestplot确实提供了一个选项来设置图形宽度,恰当地命名为graphwidth,它需要一个unit参数:例如,

forestplot(tabletext,
       test_data$coef,
       test_data$low,
       test_data$high,
       graphwidth = unit(5, "cm"))

如果您想让绘图区域比例独立于导出功能,这可能是一个稍微优雅的选择。


推荐阅读