Create separate functions for plotting, and only use plotting on testing/visualisation functions, not on the functions running in the main loop.