ipython下matplotlib不显示图片

时间:2015-05-26 20:37:40   收藏:0   阅读:5159

1- 问题描述

1 import numpy as np
2 import matplotlib.pyplot as plt
3 
4 x = np.arange(0, 5, 0.1);
5 y = np.sin(x)
6 plt.plot(x, y)

  没有任何反应,只显示 [<matplotlib.lines.Line2D at 0x7f1885750990>] 


2- 解决方法

  使用 plt.savefig() 保存图片

1 import numpy as np
2 import matplotlib.pyplot as plt
3 
4 x = np.arange(0, 5, 0.1);
5 y = np.sin(x)
6 plt.plot(x, y)
7 plt.savefig(sin.png)

 

PS: 本人环境 OpenSUSE13.2 + ipython

  谷歌百度上很多帖子说改/usr/lib64/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc文件的backend属性为TkAgg或Gtk3Agg等,试验均无法在交互界面直接显示图片,最终只能选择savefig保存图片。

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!