[IPython-User] qtconsole

Francesco Montesano franz.bergesund@gmail....
Tue Aug 28 09:01:51 CDT 2012


Dear Ipythoners,

I have just begun to use the qtconsole to mostly because I want to see
if vim-ipython (https://github.com/ivanov/vim-ipython) helps to speed
me up when doing matplotlib plots and checks from the console.
Up to now I've always used standard ipython (version 0.12.1)

As I almost always use numpy and matplotlib I've set in the ipython_config.py
lines = """
import numpy as np
import matplotlib.pyplot as plt
plt.ion()
print("")
print("Numpy and matplotlib.pyplot imported as np and plt. Interactive mode on")
"""
if hasattr(app, 'exec_lines'):
    app.exec_lines.append(lines)
else:
    app.exec_lines = [lines]

so that I start ipython with my standard setting. (If it is of any
use, my default matplotlib backend is Qt4Agg)

>From my understanding to have ipython qtconsole to show up a window
with matplotlib plot I have to call it with the --pylab option or to
use %pylabe inside the console.

The probelm (ipython qtconsole --pylab):
take the following scritp:
#####test.py#####
import matplotlib.pyplot as plt
plt.plot( [1,2,3], label='test' )
plt.legend()
plt.draw()
###end test.py###

If I paste the lines in the qtconsole the plot shows up as expected
If I do %run test.py nothing shows up and if afterwards I try to plot
anything else nothing happens.
But if I substitute plt.draw() with plt.show() or if I call the latter
in the console the plot is shown and then I can continue adding lines,
making other figures etc.

This behaviour shows up also in the the notebook. However in the
standard ipython terminal I don't need the show command to have the
plot window pop out.

I see it as an inconsistency between the three "interfaces" of
ipython, but I don't know if this is a bug or something intrinsic in
the qtconsole and notebook.

Can anyone enlighten me on this? Thanks

Cheers,
Francesco


More information about the IPython-User mailing list