Moved plotting function to a separate thread. Main thread now just sleeps for t seconds.