R code to generate plot1