code to generate plot3