Rcode for Plot 4