code to generate plot4