R code for creating plot3