Re: [spyder] problem ploting figures in ipython with spyder

6,465 views
Skip to first unread message

David Verelst

unread,
Jan 10, 2013, 3:50:57 PM1/10/13
to spyder
Hi,

I assume that the interactive mode is switched of. In order to check whether or not interactive mode is switched on/off, use the following commands:
isinteractive() (True for interactive, False for not)

Switching the interactive mode on/off: ion() or ioff() respectively.

When the interactive mode is switched off, you need to type show() before the figure will pop up.

Note that with IPython you also have the option to have your plots inline (in the console, instead of as a floating window). In order to toggle between the different ipython plot settings, use the spyder preference dialogue:
Tools > Preferences > IPython console > Graphics > Graphics backend: switch to inline or otherwise (I assume Qt will work fine for Ubuntu).

Note that you can find more information here:
Best regards,
David



On 10 January 2013 18:38, Leopoldo Pena <leope...@gmail.com> wrote:
Hi all,

I'm rather newbie using spyder, but I like it a lot.
I have run into some issues though, that I am not sure how to fix or if that is the expected behaviour.

This are the steps to reproduce it.

1 - Clean install of Ubuntu 12.10 64bits
2- Using USC or apt install spyder (e.g. sudo apt-get install spyder) after allowing universe repositories.
Spyder 2.1.10,
3- Open spyder.
4- Open Ipython (0.13.1) interpreter with contextual menu.
5- type: %pylab to start scientific environment with matplotlib. IT IS NOT IMPORTED on ipython by default when opening a terminal.
6- type:
             a=range(10)
             plot(a)

7- The output shows that the plot object has been generated, but nothing shows up on display, neither inline embebded or as a floating window.
Out[7]: [<matplotlib.lines.Line2D at 0x32d5610>]

Replicating these steps on the standard python terminal produces a floating figure.

Any advice?

--
You received this message because you are subscribed to the Google Groups "spyder" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spyderlib/-/k7qQ-UZc7K4J.
To post to this group, send email to spyd...@googlegroups.com.
To unsubscribe from this group, send email to spyderlib+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spyderlib?hl=en.

Leopoldo Pena

unread,
Jan 10, 2013, 6:39:35 PM1/10/13
to spyd...@googlegroups.com
Hi David,

thank you for your reply. I do not know what version of spyder you are using, but in mine 2.1.10 that does not work. Calling show() does not bring up any plot, not in interactive mode or else. However, the command plot on the standard python console works flawlessly. Importing matplotlib and plotting from a source file and running it on ipython also works. However, when i use the magic %pylab I cannot plot any figure on ipython.


Thanks for your reply anyway.

Monte Milanuk

unread,
Jan 10, 2013, 11:37:59 PM1/10/13
to spyd...@googlegroups.com
Talk about fortuitous timing!  I was looking into something this afternoon, thinking mathplotlib & ipython might do the trick especially since I already have spyder installed on my laptop (also running Ubuntu 12.10 64-bit)... got home tonight and was playing with it a bit with an example from the mathplotlib docs, but not seeing any plot appear.  Came here and promptly found this thread.

FWIW, 'isinteractive()' does return True.  In my case, the code I was trying to plot was something like:

x = randn(10000)
hist(x, 100)

Just typing 'show()' afterwards didn't do anything.  Wrapping hist() in show(), however, does work

show(hist(x, 100))

I'm not sure if this is a glitch/bug/feature that has migrated from Debian to Ubuntu, but I was kind of under the impression as well that from an ipython shell, after typing '%pylab' to load mathplotlib and get into interactive mode, that just plain 'hist(x, 100)' should display the plot without the need to wrap 'show()' around it.  Is there something else that needs fixed / adjusted, or is this yet another thing that I need to just not run the version that comes with the distro?

Monte

David Verelst

unread,
Jan 12, 2013, 3:49:57 AM1/12/13
to spyder
I am running spyder 2.2.0dev on Arch Linux, so the latest stuff that's in the repo, and IPython 0.13.1

Leopolde, is Monte's approach working for you?
fig = plot(np.arange(10))
draw() # you could also throw this one in additionally, but I am not sure it will solve anything
show(fig)

Regards,
David


--
You received this message because you are subscribed to the Google Groups "spyder" group.
To view this discussion on the web visit https://groups.google.com/d/msg/spyderlib/-/L7zNhPx39mUJ.

Leopoldo Pena

unread,
Jan 14, 2013, 10:48:03 AM1/14/13
to spyd...@googlegroups.com
Hi all,

wow, that is it. Both approaches work from the ipython terminal.

1- show(plot(a))
2- a = plot(a), show(a)

Isn't this a strange behaviour? Should not %pylab magic allow you simply to plot(a) from ipython without need of explicitly calling the show() function?

I am not sure if this is a but or a 'feature', but it seems to be related to spyder integration with ipython. I can open a standard ipython  console from the launcher or terminal, call %pylab and get the desired functionality (plot(a) actually showing the plot without calling show()).

Where can I report this?

Thanks!

David Verelst

unread,
Jan 16, 2013, 4:38:44 AM1/16/13
to spyder
Hi,

I am not a developer here, but I don't think that is intended behaviour. On other platforms, such as mine, it works as expected (no need to wrap it in show()). As Monte mentioned, maybe this is an issue related to the Debian/Ubuntu package? I don't know if it will help, but you could try to run spyder from source (see https://code.google.com/p/spyderlib/wiki/NoteForBetaTesters). As a quick recap:
* uninstall any spyder version on your system
Now you have 2 options:
* grab the source and install: python setup.py install
or, the bootstrap method, running it directly from the source directory
* python bootstrap.py --help

Regards,
David




To view this discussion on the web visit https://groups.google.com/d/msg/spyderlib/-/zzdv8jDk9iYJ.

Monte Milanuk

unread,
Jan 21, 2013, 7:33:23 PM1/21/13
to spyd...@googlegroups.com
On 01/16/2013 01:38 AM, David Verelst wrote:
> Hi,
>
> I am not a developer here, but I don't think that is intended behaviour.
> On other platforms, such as mine, it works as expected (no need to wrap
> it in show()). As Monte mentioned, maybe this is an issue related to the
> Debian/Ubuntu package? I don't know if it will help, but you could try
> to run spyder from source

Yeah... I've been kicking this idea around, but not sure I want to
commit just yet - mainly because I'm normally a fan of using the package
manager on systems like this as much as possible. Kind of a six one
way, half-dozen the other dilemmas as far as which one is more
frustration - dealing with out-of-date semi-broken version supported by
the system package manager, or compiling from source and having to hunt
down dependencies manually and pin packages at specific versions to
support the same. I haven't tried it for spyder, so it may be a lot
less painful than that... but BTDT in the past.

FWIW... I wonder if part of the problem ties back to the fact that
spyder (2.1.10 in this case) has problems with recognizing the ipython
installation. If I set the option in the preferences to start an
ipython kernel at startup I get all sorts of errors/warnings in the
internal console log... and several of the ipython option check boxes
are greyed out, including starting an ipython interpreter console at
startup - citing the reason as that it (spyder) can't find a version of
ipython >= 0.10 installed on the computer in question. Odd, since it'll
let me manually open an ipython interpreter from the console window
menu, and ipython is clearly @ 0.13 release version on this machine.


Jed Ludlow

unread,
Jan 21, 2013, 9:24:46 PM1/21/13
to spyderlib

Yeah... I've been kicking this idea around, but not sure I want to commit just yet - mainly because I'm normally a fan of using the package manager on systems like this as much as possible.  Kind of a six one way, half-dozen the other dilemmas as far as which one is more frustration - dealing with out-of-date semi-broken version supported by the system package manager, or compiling from source and having to hunt down dependencies manually and pin packages at specific versions to support the same.  I haven't tried it for spyder, so it may be a lot less painful than that... but BTDT in the past.

Running for source is really simple with Spyder as it runs right along side your installed version without any conflict. Simply pull down the source from the project website, run bootstrap.py from the main directory, and you should be running. More details here:


Again, I would recommend running directly from source using the bootstrap script.


FWIW... I wonder if part of the problem ties back to the fact that spyder (2.1.10 in this case) has problems with recognizing the ipython installation.  If I set the option in the preferences to start an ipython kernel at startup I get all sorts of errors/warnings in the internal console log... and several of the ipython option check boxes are greyed out, including starting an ipython interpreter console at startup - citing the reason as that it (spyder) can't find a version of ipython >= 0.10 installed on the computer in question.  Odd, since it'll let me manually open an ipython interpreter from the console window menu, and ipython is clearly @ 0.13 release version on this machine.


You should definitely expect odd behavior when running any IPython > 0.10 with Spyder 2.1.X. IPython has changed dramatically from 0.10 to the current 0.13 release, and Spyder 2.1.X was designed around IPython 0.10. I can say, however, that IPython 0.13 works great with Spyder 2.2, another benefit to running from the current development source.

Monte Milanuk

unread,
Jan 23, 2013, 7:50:07 PM1/23/13
to spyd...@googlegroups.com
On 01/21/2013 06:24 PM, Jed Ludlow wrote:

> Running for source is really simple with Spyder as it runs right along
> side your installed version without any conflict. Simply pull down the
> source from the project website, run bootstrap.py from the main
> directory, and you should be running. More details here:
>
> http://code.google.com/p/spyderlib/wiki/NoteForBetaTesters
>
> Again, I would recommend running directly from source using the
> bootstrap script.
>

Okay, thanks a bunch for that. Definitely not the 'nightmare' I was
anticipating. Most of the ipython issues seem to be fixed in 2.2.0, and
ipython starts up automatically with pylab enabled, very nice. The
plots are now functioning, but are inline, not as a separate plot
window. Is there an easy way to change that?

I presume that once 2.2.0 is considered stable and release-ready I
should be able to just run python setup.py to 'permanently' install the
new version (after removing the system installed version)?

TIA,

Monte


Monte Milanuk

unread,
Jan 23, 2013, 7:59:19 PM1/23/13
to spyd...@googlegroups.com
On 01/23/2013 04:50 PM, Monte Milanuk wrote:
> The plots are now functioning, but are inline, not as a separate plot
> window. Is there an easy way to change that?
>

Disregard this part... found it. :/

Jed Ludlow

unread,
Jan 23, 2013, 7:59:31 PM1/23/13
to spyderlib
On Wed, Jan 23, 2013 at 5:50 PM, Monte Milanuk <memi...@gmail.com> wrote:
Okay, thanks a bunch for that.  Definitely not the 'nightmare' I was anticipating.  Most of the ipython issues seem to be fixed in 2.2.0, and ipython starts up automatically with pylab enabled, very nice.  The plots are now functioning, but are inline, not as a separate plot window.  Is there an easy way to change that?

I presume that once 2.2.0 is considered stable and release-ready I should be able to just run python setup.py to 'permanently' install the new version (after removing the system installed version)?

TIA,

Monte


IPython graphics mode can be set under the Preferences...IPython console...Graphics tab. And, yes, once 2.2 is fully ready to go you can either run "setup.py install" or use one of the other typical prepackaged methods of install.
 

Leopoldo Pena

unread,
Jan 29, 2013, 1:47:29 PM1/29/13
to spyd...@googlegroups.com
Running Spyder 2.2 beta and loving it. All the issues are gone. Looking forward to the final release!

Keep up the good work!

SUNIL SHARMA

unread,
Jul 18, 2016, 4:53:00 PM7/18/16
to spyder
Hi I am using spyder 2.3.8 it works fine....the command suggested by David %pylab will enable you to use features of matplotlib. Alternativeli you can also download pylab separately and use plot functions.
Reply all
Reply to author
Forward
0 new messages