Modified the R code for plot1