Copy over from plot3.R