code to construct plot2