plot3.R produces correct plot; small code cleanup