code to generate plot2