On 7/15/07, Paul Kienzle <[EMAIL PROTECTED]> wrote: > Hi, > > I don't see an obvious way to remove a line from an axes object. > > Shall I add remove_child(h) which searches through all the lists > of containers and removes the one that I don't want?
That's one way to do it, but you might consider something along the lines -- every time someone adds an Artist anywhere in the figure, they add an entry into a Figure remove dictionary that maps the artist to a function to remove it class Figure: def register_remove(self, artist, func): 'register a function to remove an artist' self.removemap[artist] = func self.lastArtist = artist # this can be used to handle Gael's request def remove_artist(self, artist): 'remove the artist' func = self.removemap.get(artist, None) if func is None: return func() # poof, it's gone del self.removemap(artist) def remove_last(self): 'remove the most recently registered artist' self.remove_artist(self.lastArtist) self.lastArtist = None class Axes: def add_line(self, line): self.figure.register_remove(line, lambda x: self.lines.remove(line)) self.lines.append(line) Then the user won't need to know whether the artist is stored by the Axes, Axis, XTick, etc... This is likely more efficient and easier to implement than recursively searching.... Users can then: line, = ax.plot(something) fig.remove_artist(line) or ax.fill(something) fig.remove_last() and a pylab interface will be trival def remove_last(): gcf().remove_last() JDH ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel