switched from dev.copy() to png() to create plot3.png. Corrected format of legend