Code for plot 3.