R code to generate plots and the plots