admin管理员组文章数量:1122846
I am trying to align a forest plot in R with a data table of the values. The data table ends prior to the last data point. My code and plot with dummy labels are below. Thanks for your help!!
p <-
ggplot(forest_plot_data, aes(x = est, y = order, xmin = low, xmax = upp))+
geom_vline(xintercept = 1, linetype='dashed', color='black')+
geom_pointrange(shape = 22, size=0.8) +
theme_classic() +
scale_y_discrete(limits = forest_plot_data$order) +
scale_x_continuous(name='Adjusted odds ratio (95% confidence interval) of mortality')+
theme(axis.text.y = element_blank(),
axis.title.y = element_blank(),
axis.title.x = element_text(family='serif', size=14),
axis.text.x = element_text(family='serif', size=12),
plot.margin = margin(40,20,60,-1),
axis.ticks.y = element_blank(),
axis.line.y = element_blank())
data_table1 <- ggplot(data = forest_plot_data) +
geom_text(aes(x=0, y = order, label=group), hjust=0, family='serif', size=5, vjust=0) +
geom_text(aes(x=0.052, y = order, label=var), hjust=0, family='serif', size=5, vjust=0) +
geom_text(aes(x=0.09, y = order, label=label), hjust=1, family='serif', size=5, vjust=0)+
theme_void() +
theme(plot.margin = margin(20,-3,40,20))
p_total <-
plot_grid(data_table1, p, ncol=2, align='h',axis='b')
p_total +
annotate("richtext", x=0.01, y=0.96, label='**Characteristic**',
family='serif', size=5, hjust=0, fill=NA, label.color=NA)+
annotate("richtext", x=0.4, y=0.96, label="**aOR (95% CI)**",
family='serif', size=5, hjust=0, fill=NA, label.color=NA)
本文标签: rplotgrid graphs not aligningStack Overflow
版权声明:本文标题:r - plot_grid graphs not aligning - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309454a1934029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论