我在IPython中運行IPython QT控制檯在Linux上有以下代碼。IPython繪製內聯不顯示
%pylab inline
Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
fig = figure()
ax = fig.add_axes()
ax = fig.add_axes([0,500, 0, 5000])
ax.plot([1,2,3,44], [4,4,55,55])
Out[5]: [<matplotlib.lines.Line2D at 0x3d8e7d0>]
fig
Out[6]: <matplotlib.figure.Figure at 0x3d25fd0>
fig.show()
/usr/lib/pymodules/python2.7/matplotlib/figure.py:362: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "
我一直在努力使這項工作了一段時間,我試着matplotlib.use()
手動更改後端Qt4Agg
,GTK
等沒有運氣。即使我撥打display()
,也會發生在IPython notebook
之間。
任何想法如何讓內聯繪圖工作?
標記Jakob的答案是答案,但兩者都是真實的。我必須用新副本替換matploblibrc文件,使用--pylab = None啓動IPython QT Console,然後在控制檯中手動輸入%pylab內聯。不知怎的,這解決了這個問題。
如果你不是一個專家,並害怕從源代碼構建,你可以嘗試從軟件存儲庫進行安裝,即apt-get,yum等 – rafee