2017-10-09 15 views
-1

相続人は、私は私の通訳としてjupyter qtconsoleを使用してmatplotlib.pyplotにしようとしています:することはできません再プロット図

In [1]: import matplotlib.pyplot as plt 
In [2]: plt.plot([1,2,3]) 
Out[2]: [<matplotlib.lines.Line2D at 0x7ab5710>] 
In [3]: plt.show() 
plt.plot([4,5,6]) 
Out[4]: [<matplotlib.lines.Line2D at 0x7d8d5c0>] 
In[5]: plt.show() 
In[6]: plt.figure(1).show() 
c:\python35\lib\site-packages\matplotlib\figure.py:403: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure 
    "matplotlib is currently using a non-GUI backend, " 

両方In[3]と、正常出力In[5]データのインラインプロット。 In[6]は、私の2番目の数字を置き換える試みです。残念ながら、非GUIバックエンドに関するエラーメッセージが表示されています。

理想的なのは、まずデータをプロットして(例えばスクリプトを使用して)、インタプリタを使ってプロットを修正し、それを再配置し、変更が好きかどうかを確認してください。上記の設定を使用しても可能ですか?

EDIT

なっ重複を持つ2つの主な相違点があります。他の質問で

  • OPはpylabを使用しているに関する他の質問には説明がありません
  • 廃止されました私の最後のポイント。それで、数字が出てこない理由を説明します。しかし、それは質問に答えません。ユーザーが既存のプロットを変更して自由にそれを置き換えることができるシンプルな機能インタフェースを得るには?
+2

可能な複製(https://stackoverflow.com/questions/15724747/showing-the-plot-window-more - 一度) – jotasi

答えて

0

pythonコンソールまたはスクリプトの動作は、確かにjupyter qt consoleとは少し異なります。 Pythonスクリプトの場合this answerは完全に正しいです:plt.show()を呼び出した後でもう表示される図はありません。
jupyter qtコンソールでは、異なるバックエンドが使用されます。これは、デフォルトで自動的に数字をインラインでプロットします。これにより、オブジェクト指向のAPIを使用し、FigureとAxesのハンドルで作業できるようになります。

ここでは、図形ハンドルをセル内に記述するだけで図が表示されます。 [回以上プロットウィンドウを表示]の

In [1]: import matplotlib.pyplot as plt 

In [2]: fig, ax = plt.subplots() 

In [3]: ax.plot([1,2,3]) 
Out[3]: [<matplotlib.lines.Line2D at 0xb34a908>] 

In [4]: plt.show() # this shows the figure. 
# However, from now on, it cannot be shown again using `plt.show()` 
 
# change something in the plot: 
In [5]: ax.plot([2,3,1]) 
Out[5]: [<matplotlib.lines.Line2D at 0xb4862b0>] 

In [6]: plt.show() # this does not work, no figure shown 

# However, just stating the figure instance will show the figure: 
In [7]: fig 
Out[7]: # image of the figure 

関連する問題