Errors:
RuntimeError: main thread is not in main loopTcl_AsyncDelete: async handler deleted by the wrong thread
Solution:
import matplotlib as mplmpl.use('Agg')import matplotlib.pyplot as plt