如何在 Python 中将情节捕捉到图像中?
How to capture a plot into an image in Python?
我阅读并尝试了此 question 中的答案。但是,它在给定的路径中保存了一张图片,我可以打开它,但是它全是白色的,我不知道如何正确保存它。
Mention: 最初的情节制作得很好。
我的代码是:
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')
我怎样才能使这个工作?
最后尝试写plt.show()
,即。在 plt.savefig()
.
之后
我阅读并尝试了此 question 中的答案。但是,它在给定的路径中保存了一张图片,我可以打开它,但是它全是白色的,我不知道如何正确保存它。 Mention: 最初的情节制作得很好。
我的代码是:
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')
我怎样才能使这个工作?
最后尝试写plt.show()
,即。在 plt.savefig()
.