我是R的新手,正在使用metafor
包的forest.default
实现创建具有数据集的森林图(我在森林图的数据中只有x
,ci.ub
和ci.ub
)
我快完成了,我的绘图看起来与this相似,除了我的数据超出了图形顶部的黑色水平边框之外。我使用了该方法,但是我总是将一个森林图与水平边框放在同一行,并且如here所述,用白线叠加也无济于事。
我的问题是这样的:如何为我的数据集添加间隙以使森林图本身向上移动黑色边框?This is the image of the plot currently with the border (currently superimposed with a white line) cutting through my data
谢谢!
编辑:这是代码的片段
require(metafor)
metafor::forest(
x = as.vector(t(data_set[, forest_plot$mean])),
xlim = c(min_x_value - 2 * (plot_span), max_x_value),
alim = c(min_x_value , max_x_value),
ci.lb = as.vector(t(data_set[, forest_plot$low])),
ci.ub = as.vector(t(data_set[, forest_plot$high])),
col = "darkgoldenrod4",
ilab = display_data_matrix,
ilab.pos = 4,
annotate = FALSE,
slab = NA,
ilab.xpos = c(min_x_value - 2 * plot_span, min_x_value - 1.5 * plot_span, min_x_value - 0.75 * plot_span, min_x_value - 0.25 * plot_span),
rows = row_groupings,
xlab = paste(measure, ep_type, ep)
)
# print("e")
text(min_x_value - 2* plot_span, subgroup_rows, col = "brown3", pos = 4 , subgroup_titles, cex = 1.2)
header_line <- dim(data_set)[1] + gaps + 1
text( c(min_x_value - 2 * plot_span,
min_x_value - 1.5 * plot_span,
min_x_value - 0.75 * plot_span,
min_x_value - 0.25 * plot_span),
pos = 4,
cex = 1.4,
col = "darkorchid4",
header_line, c("Trial", "Randomized Treatment", "N Arm", "Time") )
abline(h=dim(data_set)[1]+1, lwd=2, col="white")
最佳答案
您需要调整ylim
参数。请执行下列操作:
sav <- forest(x = [...])
sav
(其中
[...]
是其余的所有代码)。然后查看ylim
的默认值是什么。通过将2加到上限值(因为您为子组标题添加了两行)来进行调整,然后在对ylim=c(lower,upper)
的调用中使用forest()
。