我在做量化回测时,遇到下面这样的错误提示,而且spyder软件中没有图型输出。
<IPython.core.display.Javascript object>
<IPython.core.display.HTML object>
<IPython.core.display.Javascript object>
<IPython.core.display.HTML object>
由于spyder的控制台是IPython提供的,所以就查看了一下IPython的相关文档,参考文档如下:
https://nbviewer.jupyter.org/github/ipython/ipython/blob/6.x/examples/IPython%20Kernel/Index.ipynb
查看文档发现,IPython支持以下格式的输出:
JavaScript
HTML
PNG
JPEG
SVG
LaTeX
PDF
所以,有理由相信spyder软件也可以有图像png或jpeg格式的输出。
解决方法:
1,导入 IPython display functions.
from IPython.display import (display, display_html, display_png, display_svg)
import matplotlib.pyplot as plt
........中间是自己写的代码 .....
plt.figure()
df.plot() #根据自己定义的数据对象名称,替换掉df
plt.show()
**
2,当然如果程序代码中有如下 这样的语句,记得一定要删除掉。
%matplotlib inline
大功告成,即可在spyder中正常显示图像。