R code for plot1