[Numpy-discussion] a simple examplr showing numpy and matplotlib failing

Santanu Chatterjee santanu.chatter@gmail....
Tue Dec 1 14:15:24 CST 2009


Hi Mathew,
    I saw your email and I was curious about it. I tried your code and it
does work for me without any problem.

Santanu

On Tue, Dec 1, 2009 at 2:58 PM, Michael Droettboom <mdroe@stsci.edu> wrote:

> Hmm... works for me. What platform, with how much physical and virtual RAM?
>
> One thing you may want to try is to completely destroy the figure each
> time:
>
> if fig:
> fig.clf()
> fig=None
>
> Mike
>
> Yeates, Mathew C (388D) wrote:
> >
> > Click on “Hello World” twice and get a memory error. Comment out the
> > ax.plot call and get no error.
> >
> > import numpy
> >
> > import sys
> >
> > import gtk
> >
> > from matplotlib.figure import Figure
> >
> > from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as
> > FigureCanvas
> >
> > ax=None
> >
> > fig=None
> >
> > canvas=None
> >
> > def doplot(widget,box1):
> >
> > global ax,fig,canvas
> >
> > data=numpy.zeros(shape=(3508,125,129))
> >
> > plot_data=data[0,0:,0]
> >
> > if canvas:
> >
> > box1.remove(canvas)
> >
> > canvas=None
> >
> > if ax:
> >
> > ax.cla()
> >
> > ax=None
> >
> > if fig: fig=None
> >
> > fig = Figure(figsize=(5,5), dpi=100)
> >
> > ax = fig.add_subplot(111)
> >
> > mif=numpy.arange(plot_data.shape[0])
> >
> > #if the next line is commented out, all is good
> >
> > ax.plot(plot_data,mif)
> >
> > canvas = FigureCanvas(fig)
> >
> > box1.pack_start(canvas, True, True, 0)
> >
> > canvas.show()
> >
> > def delete_event(widget, event, data=None):
> >
> > return False
> >
> > window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> >
> > window.connect("destroy", lambda x: gtk.main_quit())
> >
> > box1 = gtk.HBox(False, 0)
> >
> > window.add(box1)
> >
> > button = gtk.Button("Hello World")
> >
> > box1.pack_start(button, True, True, 0)
> >
> > #window.add(box1)
> >
> > button.show()
> >
> > button.connect("clicked", doplot, box1)
> >
> > box1.show()
> >
> > window.set_default_size(500,400)
> >
> > window.show()
> >
> > gtk.main()
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091201/265aba6c/attachment.html 


More information about the NumPy-Discussion mailing list