import matplotlib.pyplot as pltimport numpy as npimport pandas as pd......#type(forecast)=<class 'pandas.core.frame.DataFrame'>pic01=m.plot(forecast)pic01.show()
我上网查了一下,在遇到show()方法无法显示图片或者图片一闪而过,解决方案分两步:
1.加头文件,完整头文件如下:
import pandas as pdimport matplotlib as mplimport matplotlib.pyplot as pltimport numpy as npfrom numpy import *
2.调用matplotlib.pyplot.show()方法:
完整代码为:
import pandas as pdimport matplotlib as mplimport matplotlib.pyplot as pltimport numpy as npfrom numpy import *......#type(forecast)=<class 'pandas.core.frame.DataFrame'>pic01=m.plot(forecast)plt.show() #是plt.show()而不是pic01.show()pic01.savefig('temp.png') #存储图片,可选