Reputation: 19
Code below should show the same image (green background) both when using .savefig() and .show(), but the savefig image is blank. I know that .show() clears the figures but I call it after .savefig(), so it isn't the case here. Both plt.savefig() and fig.savefig() produce the same blank image.
Code (I'm using Python 3.6.8):
from matplotlib import pyplot as plt
def test(dpi=100):
fig = plt.figure(figsize=(12.8, 7.2), dpi=dpi)
fig.patch.set_facecolor('#a8bc95')
plt.savefig("test.png")
plt.show()
test()
Upvotes: 0
Views: 252