0

I read and tried the answers from this question. However, it saves a picture in the given path and I can open it, but it is all white and I do not know how to save it properly. Mention: Initially the plot is made properly.

My code is:

import pandas as ps
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
%matplotlib inline

plt.figure(figsize=(10,8))
x = df.index
y = df.val
plt.plot(x, y, c='b',label='quality')

plt.xlabel('datetime')
plt.ylabel('values')
plt.legend(loc='best')
plt.title('Qualities')
plt.show()

plt.savefig('foo.png')

How can I make this work?

Ariadne R.
  • 452
  • 11
  • 24

1 Answers1

1

Try to write plt.show() at last , ie. after plt.savefig().

Dharman
  • 30,962
  • 25
  • 85
  • 135
Shiv
  • 144
  • 9