I create several plots with matplotlib and use Pycharm (Community Edition). However, sometimes I have RuntimeError: main thread is not in main loop error. The description and solution to this problem is here. When I try the solution (code below) from this link then I cannot see any plots. Previously they were opened in separate Python 3.9 window.
How can I solve the problem of RuntimeError and still have output shown immediately after running the code in Pycharm?
import matplotlib.pyplot as plt
#matplotlib.use('Agg') #can be used as alternative
plt.switch_backend('agg')
import matplotlib