如何在Python中将图捕获到图像中?

问题描述

我阅读并尝试了此question的答案。但是,它会将图片保存在给定的路径中,我可以打开它,但是它全是白色的,我不知道如何正确保存它。 提及:最初地块制作正确。

我的代码是:

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()之后。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...