code for plot2