Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

python - Matplotlib plots not displaying in 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() 

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.

Have I misunderstood how sublimetext is meant to be used?

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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

EDIT: 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...