I have generated 3 bar plots using barplot() function. Now I need to combine these 3 plots in a single column and get another new plot. I have used cowplot to do so however it showed warning message
In as_grob.default(plot) :Cannot convert object of class matrixarray into a grob.
I know it is easier with ggplot. But I find it hard to write this code in ggplot. Can someone please give me a solution? I am not an expert but I tried my best but could not find a solution. My code:
k <- readr::read.csv("maxcor_r_p.csv", TRUE, ",")
cols <- c("azure3", "#003f5c")[(k$p < 0.05) + 1]
maxi <- barplot(
k$r,
names.arg = k$parameter,
ylab = "Correlation coefficient",
col = cols,
main = expression("T"[max]),
las = 2
)
l <- readr::read.csv("meancor_r_p.csv", TRUE, ",")
cols <- c("azure3", "#27e52a")[(l$p < 0.05) + 1]
meany <- barplot(
l$r,
names.arg = l$parameter,
ylab = "Correlation coefficient",
col = cols,
main = expression("T"[mean]),
las = 2
)
m <- readr::read.csv("precipcor_r_p.csv", TRUE, ",")
cols <- c("azure3", "#27bac6")[(m$p < 0.05) + 1]
preci <- barplot(
m$r,
names.arg = m$parameter,
ylab = "Correlation coefficient",
col = cols,
main = expression("Precipitation"),
las = 2
)
cowplot::plot_grid(
maxi, meany, preci,
ncol = 1, align = "v", axis = 1
)