error checking for plotting