code and plot for plot3