I am trying to use the plot_grid function from cowplot R package to put two plots together. However, I was getting the below error:
Error in switch(x[[2]][[1]]$name, C_abline = C_abline(x[[2]]), C_plot_new = C_plot_new(x[[2]]), : EXPR must be a length 1 vector
Therefore, testing both graphics I discovery that the error came from a ggplot which I used grid_text. Thus, in my example here I included only one plot. With the below you can reproduce the problem:
library(cowplot)
library(ggplot2)
library(ggforce)
library(grid)
### Example
circles <- as.data.frame(cbind(c(0.5, 1.5, 2.5), c(1, 2, 1), c(0.2, 0.2, 0.2)))
# Behold the some circles
ggplot() + geom_circle(aes(x0=V1, y0=V2, r=V3, fill=c("red", "blue", "green")), data=circles)+
theme_bw() + ylab(expression(symbol('\253'))) + xlab(expression(symbol('\253')))+ theme(legend.position="none",
axis.title.x=element_text(size = 50),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.title.y=element_text(size = 50),
axis.text.y=element_blank(),
axis.ticks.y=element_blank())
grid.text("Distinct", x = unit(0.04, "npc"), y = unit(0.80, "npc"))
exP <- recordPlot()
plot_grid(exP)
I would be glad to receive any idea how to use plot_grid on that kind of object (ggplot + grid_text).


grid.arrange?recordPlot()does. I recommend not to use it, in particular when you're only working with grid graphics, as is the case here. See my proposed answer for alternatives.