Problem Description
When you use the plt.savefig() command to save a picture in matplotlib.plot, occasionally there will be a blank picture when the picture is saved, click and open it. At this time, your code is often like this:
import matplotlib.pyplot as plt
"""你的一堆代码"""
plt.show()
plt.savefig("××××.png")
solution
Save the picture first, then show() the picture.
Because show() is equivalent to creating a new blank figure (somewhat similar to the figure command in MATLAB), the blank picture will be saved after calling the show() command.
import matplotlib.pyplot as plt
"""你的一堆代码"""
plt.savefig("××××.png")
plt.show()
The problem is solved perfectly!