python: matplotlib window does not show graph in interactive mode

Bug #220137 reported by AlexanderL
10
Affects Status Importance Assigned to Milestone
matplotlib
New
Undecided
Unassigned
matplotlib (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

When trying to intactively plot data with matplotlib in python the graphic window pops up but shows no graph and cannot be closed without crashing the script. This has been working in hardy beta but does not any more with the RC. I tried it with Compiz on and off with the same result
Here is a little script to test:

from numpy import *
from scipy import *
from matplotlib import *
from pylab import *

ion()
figure(1)
plot([1,2,3],[1,2,3])
raw_input('press any button to continue: ')
close(1)

I am using Hardy Heron Release Candidate.

Related branches

Revision history for this message
Morten Kjeldgaard (mok0) wrote :

I failed to reproduce this bug on a freshly upgraded hardy system. The python-matplotlib version I am using is 0.91.2-0ubuntu1.

Can you provide more information, please?

Revision history for this message
AlexanderL (alexander-lurf) wrote :

I am using the same version of python-matplotlib.
This system has been installed from a Beta CD and upgraded to RC.

The plot window works fine as long as interactive mode is turned off and I use show() to create the window. But this does not give me the behaviour I am looking for as I want to close the window within my program.

The window's title bar looks normal, but the rest of the window is gray with neither the matplotlib toolbar nor the graph visible.

I am sorry, I don't know what information I could give you additionally.

The example I gave above works fine if I comment ion() and put a show() before raw_input. Like this:

from numpy import *
from scipy import *
from matplotlib import *
from pylab import *

#ion()
figure(1)
plot([1,2,3],[1,2,3])
show()
raw_input(':')
close(1)

Revision history for this message
Scott Kitterman (kitterman) wrote :

I'm not sure if this is a bug or change by design. I get the same behavior as you describe, but if I reverse the figure(1) and plot lines it works.

Revision history for this message
Scott Kitterman (kitterman) wrote :

Works as in plots. It still doesn't close the window after a keyboard entry.

Revision history for this message
AlexanderL (alexander-lurf) wrote :

How could that be a change in design to make interactive plots useless?

What do you mean by 'to reverse figure(1) and plot lines' and 'works as in plots'?

Thanks a lot for your help in advance!

Revision history for this message
AlexanderL (alexander-lurf) wrote :

What I figured out now is that it seems to work that way:

from numpy import *
from scipy import *
from matplotlib import *
from pylab import *

ion()
plot([1,2,3],[1,2,3])
figure(1)
raw_input(':')
close(1)

However if I want to open another interactive plot I have to name it figure 1 as well. That is because I name the figure after I call the plot command, but that is the only way the interactive plot works.

Any idea what the problem is? Any solution?

Revision history for this message
Albert Damen (albrt) wrote :

This is documented in /usr/share/doc/python-matplotlib/INTERACTIVE :

To use matplotlib interactively from the prompt, you need a special
interpreter that doesn't enter the gtk mainloop. One is provided in
examples/interactive.py. The coew functionality of this interpreter
was provided by Brian McErlean and John Finlay. See the header for
more info.

Using interactive.py (from the python-matplotlib-doc package) interactive plotting seems to work OK.

Revision history for this message
AlexanderL (alexander-lurf) wrote :

Thanks a lot for you help.

But I think that this is not my problem.
Using ipython everything works fine.
Running the script directly with 'python filename.py' results in that error.

When talking about interactive plotting I mean a plot with 'ion()' - i.e. the window stays active and open while the script continues in the background.

Revision history for this message
dm (jan-rauberg) wrote :

I get a similar problem with the interactive mode. I use the this script:

import pylab as p
import numpy as n
p.ion()
p.figure(1)
a = n.array([1,2,3])
p.clf()
p.plot(a)
p.show()

So I get the plot window, but I can't enter something in the python shell.
Also If I close the plot window the python shell doesn't return.
I can only use ctrl-c to terminate the python process.
With Gutsy I never had this behavior. So I thing it is a bug.
I've upgraded from Gutsy to Hardy, perhaps it work right with a clean new installation?

Revision history for this message
dm (jan-rauberg) wrote :

Ok, ok, I have solved my problem. In Ubunut 7.10 the default GUI-backend for matplotlib was TKagg, in 8.04 it is GTKagg,
which needs a special python shell to work correctly in interactive mode.
So I switched back to TKagg and everything works in the right manner.

Revision history for this message
AlexanderL (alexander-lurf) wrote :

Thats great news!

How can I switch to another GUI-backend?

Revision history for this message
dm (jan-rauberg) wrote :

In /etc/ you have the 'matplotlibrc' file.
Open it with sudo in an editor of your choice.
In line 29 you can find the entry 'backend'.
Edit it to TKAgg.
That's it.

Revision history for this message
AlexanderL (alexander-lurf) wrote :

Thanks a lot, that worked for me as well!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package matplotlib - 0.91.2-2ubuntu1

---------------
matplotlib (0.91.2-2ubuntu1) intrepid; urgency=low

  * Merge from Debian unstable (LP: #233959). Remaining Ubuntu changes:
  * debian/control:
    - Change Maintainer/XSBC-Original-Maintainer field,
    - Update Build-depends: python-wxgtk2.6 -> 2.8
    - Change order of dependencies so python-gtk2 is first (LP: #223067).
  * debian/docs: adding various doc files to binary package
  * Revert to TkAgg backend instead of GTKAgg which has been the default
    in the several last Ubuntu releases. TkAgg is also the default backend
    in the Debian version. Bug (LP: #220137) seems to indicate that GTKagg
    does not work as expected, either by design or from a bug.
  * debian/rules:
    - copy debian/setup.cfg to $(CURDIR), to make TkAgg the default.
    - call dh_link for the indep target.
  * Also install /usr/share/matplotlib/matplotlib.conf, and create
    a link from /etc/matplotlibrc to /usr/share/matplotlib partly solving
    the problem described in Launchpad bug 126318.
  * debian/README.debian: add note on use of environmental variable.
  * Closing other bugs fixed by this version:
    - PDF generation is working in this version (LP: #114707)
    - personal settings file in ~/.matplotlib/matplotlibrc (LP: #124621)
    - quiver interface refactored from upstream (LP: #134919)

matplotlib (0.91.2-2) unstable; urgency=medium

  * debian/patches/bts-478237_ftbfs_gcc43.patch
    - added (Closes: #478237)
  * debian/rules
    - removed some files changes during build
  * debian/control
    - removed Depends on python-numeric-ext, python-numarray-ext (Closes:
      #478451)

matplotlib (0.91.2-1) unstable; urgency=low

  [ Piotr Ożarowski ]
  * Replace libwxgtk2.4-python with python-wxgtk2.6 in Depends
    (closes: #466470)

  [ Sandro Tosi ]
  * New upstream release (Closes: #459200, #474001, #447741, #408955)
  * debian/patches/build_fix.patch
    - edited to match new code
  * debian/rules
    - adjusted doc files installation
  * debian/docs
    - removed since the same files were already in debian/rules
  * debian/patches/matplotlibrc_fix.patch
    - edited to match new code (sync from Ubuntu)
  * debian/control
    - added "dvipng, python-configobj, python-enthought-traits (>= 2.0),
      python-qt-dev, python-qt4-dev, python-wxgtk2.6" as build-dep (sync from
      Ubuntu)
    - bump depends on python-numpy (sync from Ubuntu)
    - added "python-qt4, dvipng, python-configobj, python-enthought-traits (>=
      2.0)" to Depends (sync from Ubuntu)
    - merged Recommends into Depends
    - removed Depends on python-pypaint since that package is unavailable
    - added myself to Uploaders
  * debian/patches/bts-468977_memory_api_usage.patch
    - fixes Python API memory usage (Closes: #468977)

 -- Morten Kjeldgaard <email address hidden> Fri, 30 May 2008 14:17:03 +0200

Changed in matplotlib:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.