#ggplot2 #rdatavisulaistaion #multiplots #patchwork #graphinginR
patchwork is a package which is extension to ggplot2. It makes putting many pots together very easy. just join the plots using + or backslash. function plot_annotate, helps to annotate individual plots or all the plots patched together.
The script:
#install.packages("patchwork")
library(patchwork)
library(ggplot2)
p = ggplot(iris,aes(Species,Sepal.Length,fill =Species,color=Species))
p
p1 = p+ geom_violin()
p1
p2 = p1 + ggtitle("Geom_violin with title")
p2
p3 = p2+theme_bw()
p3
p4 = p3+labs(subtitle = "Just the 4th plot")
p4
p1
p2
p3
p4
p1+p2+p3+p4
patch =(p1+p2)/ (p3+p4)
patch+ plot_annotation(tag_level="A", tag_prefix = "fig", title=" Patchwork package ahs patched 4 plots together",
subtitle=" My subtitle", caption= " Patchwork")