Matplotlib图未以sublimetext显示 [英] Matplotlib plots not displaying in sublimetext

查看:406
本文介绍了Matplotlib图未以sublimetext显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用sublimetext 2,但是今天我注意到plt.show()函数在sublimetext中运行时似乎不起作用.

I've recently started using sublimetext 2, however I noticed today that the plt.show() function doesn't seem to work when run within sublimetext.

例如,如果我创建以下脚本:

If for example I create the following script:

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.show() 

与IDLE一起运行会生成一个图,但是使用sublimetext不会生成任何输出.它一直保持思考"状态,直到我结束输出[Finished]的python.exe进程为止.

Running this with IDLE generates a plot, however using sublimetext no output is generated. It just keeps 'thinking' until I end the python.exe process after which [Finished] is output.

我是否误解了如何使用sublimetext?

Have I misunderstood how sublimetext is meant to be used?

谢谢.

推荐答案

我的猜测是Sublime Text 2在其自己的环境中启动您的代码,并且仅捕获并显示控制台输出.使用GUI时(例如wxPython)存在相同的问题.

My guess would be that Sublime Text 2 launches your code in its own environment, and only traps and displays the console output. The same problem exists when using GUI's, such as wxPython.

另一种解决方法是打开命令提示符并手动启动(python file.py).

Another work around is to open the command prompt and launch it manually (python file.py).

编辑:此处指出在Windows下,GUI是被压制."

Here it states that "Under Windows, GUIs are supressed."

EDIT 2: Here it lists a way to fix it, right at the bottom of the page.

这篇关于Matplotlib图未以sublimetext显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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