Rcode for Plot 3