I have two plots p1 and p2 which I am trying to plot using grid.arrage. My code looks as below:
grid.arrange(p1, p2, ncol=2,
top = textGrob("Distribution across each day of the week",
gp = gpar(fontface = "bold", cex = 1.5)),
bottom = "Day of the week")
However, when I run this, I am seeing an error "Error in arrangeGrob(...) : could not find function "textGrob"
When I run only grid.arrange(p1, p2, ncol=2)
, it runs fine. But without any labels and title. However, I couldnt understand what is the problem with my code. I tried both main=...
and as well as top=...
Neither of them works.
Any suggestions?
Here are two simple png files.
When you combine them, the
top =
andbottom =
arguments work fine:EDIT BASED ON COMMENT
Create the title outside of the
grid.arrange()
call:and revise the call: