简体   繁体   English

ggplot2:无法将``添加到ggplot object

[英]ggplot2 : Can't add ` ` to a ggplot object

everyone I generated 2 ggplot figures and I would like now to add them into the same figure, to do that I simply add the + .每个人我生成了 2 个 ggplot 图,现在我想将它们添加到同一个图中,为此我只需添加+ So I have 2 plots: (1 ggtree and 1 heatmap)所以我有 2 个图:(1 个 ggtree 和 1 个热图)

and I'm trying to add them in the same plot with:我正在尝试将它们添加到同一个 plot 中:

ggplot<- gg_tr + gg_heat + plot_annotation(tag_levels="A")

But then I get the following issue message:但随后我收到以下问题消息:

Error : Can't add `gg_heat` to a ggplot object.
Run `rlang::last_error()` to see where the error occurred.
library(patchwork)
gg_tr + gg_heat

If using ggpubr::ggarrange() , you need to put a comma and not a + .如果使用ggpubr::ggarrange() ,您需要输入逗号而不是+

ggarrange(histo_qmean, histo_gmean, histo_qmed, histo_gmed,
          labels = c("A", "B", "C", "D"),
          ncol = 2, nrow = 2)

I got the same error by wrongly using + , for anyone looking for it.对于任何正在寻找它的人,我错误地使用+得到了同样的错误。

Need to add parentheses需要加括号

ggplot<- gg_tr() + gg_heat() + plot_annotation(tag_levels="A")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM