R script for plot4.