>>> plot([1,2,3,4])
> [<matplotlib.lines.Line2D instance at 0x8790d6c>]
> >>> show()
> (process:3261): GLib-GObject-CRITICAL **: gtype.c:2253:
> initialization assertion failed, use g_type_init() prior to
> this function
> Segmentation Fault (core dumped)
The problem here is that "show" starts the GUI mainloop when using a
GUI backend (GTKAgg is the default). To use the GTK, WX, or Qt
backends from a shell, you need to use a shell that starts the GUI
mainloop in a separate thread (Tkinter is special in this regard, in
that it can be use from the shell with no special threading calls, so
if you need to use the standard python shell for interactive work, you
should use the TkAgg backend). Also, you should not be using "show"
when working interactively from the shell. This is discussed in more
detail at
http://matplotlib.sourceforge.net/interactive.html
and
http://matplotlib.sourceforge.net/faq.html#SHOW
The recommended approach for using the GTK/WX/Qt backends
interactively from the shell is to use the ipython shell. ipython is
an easy install (pure python) and in addition to lots of nice
interactive features, has matplotlib support. Specifically, in the
pylab mode
> ipython -pylab
it will read your matplotlibrc file, detect your backend, issue the
proper threading and timer/idle calls as needed for GTK, WX, Qt or Tk,
import the pylab namespace and wash your dishes
Eg, you can do
ipython -pylab
Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
Type "copyright", "credits" or "license" for more information.
In [1]: hist(randn(10000), 100)
and your plot should appear automagically.
If for some reason ipython is not an option for you, and you need to
use a GTK backend from the shell, there is some template code in the
matplotlib examples directory showing how to write a custom shell with
the proper gtk threading calls.
JDH