matplotlib显示什么,虽然我叫show [英] matplotlib show nothing although i called show

查看:339
本文介绍了matplotlib显示什么,虽然我叫show的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是matplotlib的新手。

I am a newbie of matplotlib.

最近我在#Win-7 64bit#上使用#WinPython-64bit-3.3.2.1#当我键入代码时在IPython Qt控件上如下:

Recently I am using #WinPython-64bit-3.3.2.1# on #Win-7 64bit# and When I typed codes on the IPython Qt Control as below:

In [1]: plot(range(3))    
Out[1]: [<.matplotlib.lines.Line2D at 0x64ae390>] 
% There is a plot. 
In [2]: show() 
%nothing happened.

演出后应该有一个情节。但没有发生任何事情,没有错误信息。而savefig()只会保存一张空白的无花果。
我尝试了 matplotlib的解决方案虽然我通过设置backends ='GtkAgg'或'QtAgg'来调用pyplot.show(),但是没有显示我的绘图,但它没有用。

There should be a plot after show. But nothing happed, no error message. And the savefig() will only save a blank fig. I tried the solution of matplotlib does not show my drawings although I call pyplot.show() by setting backends = 'GtkAgg' or 'QtAgg', but it did not work.

谢谢你的建议。 :)


Updata1
'WinPython Interpreter.exe'用于代替'IPython QT Console.exe'
然后我键入相同的代码, show()工作。
后端设置为 GtkAgg

Updata1: The 'WinPython Interpreter.exe' is used instead of 'IPython QT Console.exe'. Then I typed the same code and the show() worked. The backend is set to GtkAgg.

我认为原因如下:

由于WinPythonInterpreter是一个命令窗口,因此需要一个新窗口来显示绘图。
IPython支持交互式数据可视化,它不需要另一个窗口。

Since WinPythonInterpreter is a command window, it need a new window to display the plot. The IPython supports interactive data visualization, it does not need another window.

Updata2 :我只想说 gcf()在QT控制台中返回了不同的引用在WinPython Interpreter中返回了相同的引用。也许这就是问题点。

Updata2: I just fount that the gcf() returned different references in the QT Console, and it returned the same reference in WinPython Interpreter. Maybe this is the problem point.


推荐答案

WinPython IPython QT控制台似乎默认为pylab在评论中建议使用内联后端作为mutzmatron。

The WinPython IPython QT console appears to default to pylab with the inline backend as mutzmatron suggested in the comments.

知道Matplotlib在哪种模式下工作可能有点混乱 Matplotlib pylab和pyplot:它们是如何相关的?

It can be a little confusing to know what mode Matplotlib is working in see Matplotlib pylab and pyplot: how they are related?

我倾向于使用Python发行版 Anaconda 它的QTConsole不会预加载pylab默认情况下你可以导入pyplot并使用show(),使用WinPython你可以通过使用windows命令提示符转到WinPython * \ python * \ Scripts目录并启动<$ c $来启动这样的IPython QT控制台c> ipython3.exe qtconsole

I tend to use the Python distribution Anaconda it's QTConsole doesn't preload pylab by default so you can import pyplot and use show(), With WinPython you can launch the IPython QT console like this by going to the WinPython*\python*\Scripts directory with the windows command prompt and launching ipython3.exe qtconsole

import matplotlib.pyplot as plt
plt.plot(range(3))
plt.show()

虽然这会停止在IPython QT控制台中的执行当情节打开时。您可以检测 plt.get_backend()正在使用哪个后端,Anaconda IPython QT控制台使用 QT4Agg Windows 7安装。

Although that halts the execution in the IPython QT console when plot is open. You can detect which backend is being used by plt.get_backend(), the Anaconda IPython QT console uses QT4Agg on my Windows 7 install.

这篇关于matplotlib显示什么,虽然我叫show的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆