1
我想在同一個圖上繪製一系列函數。該代碼似乎運行良好,但沒有圖片即將推出。只是簡單地避免<matplotlib.figure.Figure at 0xeafea58>
<matplotlib.figure.Figure at 0xeafea58>
它如何被固定?
我想在同一個圖上繪製一系列函數。該代碼似乎運行良好,但沒有圖片即將推出。只是簡單地避免<matplotlib.figure.Figure at 0xeafea58>
<matplotlib.figure.Figure at 0xeafea58>
它如何被固定?
在IPython控制檯中,確保數字顯示的最佳方式(不明確調用plt.show()
)是使用%matplotlib
模式。如果matplotlib安裝正確,它應該自動爲您的系統選擇合適的後端。
例如:
In [1]: import matplotlib.pyplot as plt
In [2]: plt.plot([1, 2, 3]) # no plot shown!
Out[2]: [<matplotlib.lines.Line2D at 0x110eac898>]
In [3]: %matplotlib
Using matplotlib backend: MacOSX
In [4]: plt.plot([1, 2, 3]) # plot shown now
Out[4]: [<matplotlib.lines.Line2D at 0x112174400>]
的%matplotlib
魔術命令只需要在每個會話中輸入一次。
謝謝@jakevdp .. yayiiii這真是一個神奇的讚美。它直接爲我選擇了一個後端,它像魔術一樣工作..非常感謝 –
我嘗試切換後端..'['TKAgg','GTKAgg','Qt4Agg','WXAgg']'但無濟於事 –
我正在使用Ipython控制檯運行它 –
**是**碼?請注意,這是預期的和期望的行爲,取決於您的設置,因此它不能被「固定」。 – ImportanceOfBeingErnest