22

Possible Duplicate:
matplotlib does not show my drawings although I call pyplot.show()

I'm a newbie to Matplotlib and have encountered this problem. I'm using a Ubuntu system. I started with Matplotlib 0.99 and realized that I really need the new feature of "triplot" in the newer versions. So I downloaded the newest version by

git clone git://github.com/matplotlib/matplotlib.git

and installed it. However, when I work with python interactively, pyplot.show() does not show me the figure I plot, nor did it responded with any error message. pyplot.show() did work in the old version of matplotlib 0.99.

To be more specific, I seemed to have no problem importing "matplotlib" or modules inside the package; I can generate pdf files of a bunch of figures, but I just can't have the figure show up by typing pyplot.show() at the end of my code. Can anyone help me? Thank you!

Community
  • 1
  • 1
user1248468
  • 221
  • 1
  • 2
  • 3
  • maybe similar question to this one: http://stackoverflow.com/questions/7534453/matplotlib-does-not-show-my-drawings-although-i-call-pyplot-show – Thanasis Petsas Mar 04 '12 at 19:10
  • How are you running your program? If you're in the standard interactive python interpreter, `show` won't work because it needs to run in a separate thread, and the interactive interpreter blocks it. `ipython` and other more advanced interactive shells are around partly for this reason. (And they have a _ton_ of useful features that the standard interactive interpreter doesn't have.) – Joe Kington Mar 04 '12 at 19:12
  • Otherwise, it's possible that you don't have the development version of `Tk` or any other gui libraries installed, and so `matplotlib` wasn't able to build the default interactive backend. – Joe Kington Mar 04 '12 at 19:13
  • For what it's worth, the latest version of Ubuntu (Ocelot) has version `1.0.1-3` and the soon-to-be-released version (Pangolin) will have `1.1.0-1` https://launchpad.net/ubuntu/+source/matplotlib . The apt-get installs usually work right out of the box and handle any other libraries. – Hooked Mar 05 '12 at 14:44

1 Answers1

16

I had the same issue and solved it by setting the appropriate display backend, following matplotlib does not show my drawings although I call pyplot.show()

There are two ways to achieve this:

1.Set the backend in your code, right after importing matplotlib:

import matplotlib
matplotlib.rcParams['backend'] = "Qt4Agg"

2.Or define your backend inside your matplotlibrc file (as given by matplotlib.matplotlib_fname()):

backend      : Qt4Agg

More information here: http://matplotlib.sourceforge.net/users/customizing.html

Community
  • 1
  • 1
Régis B.
  • 10,092
  • 6
  • 54
  • 90