plotting function, changed warnings to errors