Code for plot 2