Interactive Plotting
I notice that when using the IPython console interactive plotting doesn't work - by default you have to manually call show() which then blocks until the figure is destroyed.
If you try to turn on interactive (non-blocking) plotting with the %pylab magic the console doesn't block but the figure doesn't display properly.
Is there any chance interactive plotting can be enabled in a future release?
Thanks,
Dave
{'commit_hash': 'c6b7529',
'commit_source': 'repository',
'default_encoding': 'UTF-8',
'ipython_path': 'c:\\dev\\code\\ipython\\IPython',
'ipython_version': '0.14.dev',
'os_name': 'nt',
'platform': 'Windows-7-6.1.7601-SP1',
'sys_executable': 'C:\\dev\\bin\\Python27\\python.exe',
'sys_platform': 'win32',
'sys_version': '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'}
If you try to turn on interactive (non-blocking) plotting with the %pylab magic the console doesn't block but the figure doesn't display properly.
Is there any chance interactive plotting can be enabled in a future release?
Thanks,
Dave
print IPython.sys_info()
'commit_source': 'repository',
'default_encoding': 'UTF-8',
'ipython_path': 'c:\\dev\\code\\ipython\\IPython',
'ipython_version': '0.14.dev',
'os_name': 'nt',
'platform': 'Windows-7-6.1.7601-SP1',
'sys_executable': 'C:\\dev\\bin\\Python27\\python.exe',
'sys_platform': 'win32',
'sys_version': '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'}
Please sign in to leave a comment.
To add a little more explanation, when not in "interactive" plotting mode calling `show` will display the figure correctly but will block the console. After turning on "interactive" plotting the figure will pop up immediately after a call to `plot`, the console won't block but the plot won't display correctly and will effectively hang until a call to `close('all')` closes the figure window.
plt (804B)
Yes, the workaround with Pycharm is to add a show() after the plot() call. But that Way results in the console being locked out until the Tkinter window is closed as is the case with ipython without its –pylab switch.
If Jetbrains could figure out a '–pylab' sort of enhancement to PyCharm, that would be great.
Also if you call pylab with magic command (%pylab), then plots do not work
If you import pylab (from pylab import *), then plots work, but require additional plt.show() command.
It turns out that PyCharm offers the best support of all three of these products though you may not like how it works:
1. open a terminal window (PyCharm will open it in your project directory.)
2. run ipython
3. import your script
4. dynamic charting works.
There may be some way to create an external command that does this along with the import. I'll try that though I am fully satisfied with what I described given how much time I wasted on IEP and Spyder. Nice folks in both bases, but neither could solve this.
Your suggestion 1-4 basically boils down to don't use PyCharm for interactive plotting / data analysis which is exactly the situation we have now and isn't a solution to the limitations of PyCharm.
The discussion here and on PY-12096 and PY-7029 shows that there is a lot of demand for this feature. The last word from a PyCharm dev is that Alexander Marchuk is looking into it so I'm eagerly awaiting any developments there.
One alternative that may be easier to implement would be a bokeh plotting solution - IIUC you could have a persistent bokeh server which the IPython could talk to via the Python bokeh package.
import matplotlib as mpl
mpl.use('Qt4Agg')
The startup is a little longer though.
Anyway, I hope that the issue will be solved in Pycharm.
I started working on a plugin to get something like MATLAB cell mode in PyCharm. Cells are delimited by ## and my plugin can send the cell content (python code) to either the internal console or an external ipython running in tmux. With the second solution (external ipython in tmux), matplotlib interactive plotting works.
You can get the plugin here (download PythonCellMode.jar and install plugin from disk in PyCharm) :
https://github.com/julienr/pycharm-cellmode
It's alpha quality at the moment, but it seems to work for me.
I solved this issue in OS X Mavericks with the following steps:
1) Install PySide. I used the following guide:
http://www.pythoncentral.io/install-pyside-pyqt-on-windows-mac-linux/
2) Run the following script before plotting. You may want to add this to PyCharm - Preferences - Build,Execution,Development - Console - Python Console - Starting script.
import matplotlib as mpl
mpl.rcParams['backend.qt4'] = 'PySide'
mpl.use('Qt4Agg')
from pylab import *
ion()
This enables interactive plotting for me. For example, when I run:
x = arange(0,10,0.1)
y = sin(x)
plot(x,y)
The plot renders in a separate window, and the control returns to the console immediately.
It is important to use pt.show() (Or pylab.show()–depending on how you import matplotlib) to cause drawing. I also think that matplotlib.pyplot.ion() and ...ioff() work as expected.