R script and png file for plot 4