ggplot2 : Can't add ` ` to a ggplot object

Viewed 15957

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 +. So I have 2 plots : (1 ggtree and 1 heatmap)

and I'm trying to add them in the same plot with :

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.
2 Answers
library(patchwork)
gg_tr + gg_heat

If using ggpubr::ggarrange(), you need to put a comma and not a +.

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.

Related