Updated code to produce plot 3