make plotting function for output to device