[IPython-User] qtconsole

Francesco Montesano franz.bergesund@gmail....
Thu Aug 30 07:42:51 CDT 2012

Hi Matthias,

thanks for the reply,

2012/8/30 Matthias BUSSONNIER <bussonniermatthias@gmail.com>:
> Hi Francesco,
> Le 28 août 2012 à 16:01, Francesco Montesano a écrit :
>> 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")
>> """
> --pylab already import numpy as np and pyplot as plt.
I didn't know, I thought that imported numpy and pyplot under the same
namespace, as when importing matplotlib.pylab.

>> 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 do have the difference of showing figure when using %run vs copy and paste
> but I'm not totally surprised if I understand correctly how the %run command is supposed
> to work. (script is executed in an empty namespace, so I guess the display hook don't have effect)
> Unfortunately I can't the **difference** of behavior between 2process fronted and  normal python terminal on Os X.
> Figures never show for me if I don't specify plt.show() while using run.
> Maybe it has been fixed in more recent release.
>> 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
> Could you try on a more recent version to see if it's still present,

I've run the test.py with Ipython 0.13 and 0.14dev (cloned from github
just before writing this mail) and seen the same behaviour:
in ipython (with my ipython_config.py) the figure appears.
On ipython --pylab, qtconsole --pylab or notebook --pylab the figure
pops up only
after a call of plt.show() or if I add plt.ion() in test.py (I've just
discovered this).

It seems that with the --pylab option the 'plt.ion()' in my
ipython_config.py is ignored when executing %run test.py,
but not when a plotting command is given directly in the ipython terminal.

I have tried to substitute
> import numpy as np
> import matplotlib.pyplot as plt
in my ipython_config.py with %pylab, but the result is (as expected)
the same as using --pylab.

> Could you also file a bug report on github ?
If you think that this difference in behaviour when using or not
--pylab is a bug, I'll submit the report to github



> We are kind of low bandwidth right now
> and might forget thread on the ML.
> Thanks
> --
> Matthias
>> Cheers,
>> Francesco
>> _______________________________________________
>> IPython-User mailing list
>> IPython-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/ipython-user
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user

More information about the IPython-User mailing list