Laurie
Laurie

Reputation: 19

Matplotlib show() and savefig() inconsistent

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()

.show()

.savefig()

Upvotes: 0

Views: 252

Answers (1)

Laurie
Laurie

Reputation: 19

Updating the matplotlib version fixes the problem.

Upvotes: 0

Related Questions