16

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
  • maybe you want to use the patchwork package - then + will combine plots Commented Jun 26, 2020 at 17:37
  • Thank you it workes now Commented Jun 26, 2020 at 17:41

3 Answers 3

16
library(patchwork)
gg_tr + gg_heat
Sign up to request clarification or add additional context in comments.

1 Comment

some explanation could be useful
0

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.

Comments

-3

Need to add parentheses

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

1 Comment

This just produces error messages that R cannot find the function with the plot name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.