Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 469
iRoygbiv Avatar asked May 31 '12 10:05

iRoygbiv


People also ask

What happens if I dont use %Matplotlib inline?

In the current versions of the IPython notebook and jupyter notebook, it is not necessary to use the %matplotlib inline function. As, whether you call matplotlib. pyplot. show() function or not, the graph output will be displayed in any case.

Does matplotlib work in idle?

Download the “Install Matplotlib (for Mac)” file from my web site, and double-click it to run it. Test your installation. Start IDLE, type “import matplotlib”, and confirm that this command completes without an error.

Is PLT show () necessary?

Plotting from an IPython shell Using plt. show() in Matplotlib mode is not required.


1 Answers

More appropriate way is to just add one line in default Python build system file:

"shell": true

Or make additional Python build system with:

{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}
like image 190
theta Avatar answered Oct 10 '22 20:10

theta