code for plot4