Code for Plot 3