From: Eric F. <ef...@ha...> - 2006-01-31 21:16:43
|
Chris, Christopher Barker wrote: > Hi all, > > I'm having problems with the data limits when I use a LineCollection > > Here is the relevant code. A VectorLinecollection is a subclass of > LineCollection. ax is an Axes instance. > > ax.clear() > VLC = VectorLineCollection(t, y, theta, self.Figure, ax) > ax.add_collection(VLC) > ax.plot(t, y, 'o') > print "The lines are:", ax.get_lines() > print "AutoScaleOn:", ax._autoscaleon > print ax.dataLim.intervaly() > print ax.dataLim.intervaly().get_bounds() > ax.autoscale_view() > > > This all works fine when I call it the first time, but when I call it > again, with a new LineCollection, dataLim is not re-set. If I comment > out the add_collection call, and just do the plot, then dataLim does get > reset when clear is called, so autoscale_view obviously doesn't work. > > any ideas what's wrong? How would I force a re-set of dataLim? It is not entirely clear to me what you mean by "call it again...", but note that autoscale_view() updates the viewLim from the dataLim; it does not update the dataLim. That is done by add_line, which is called by plot, but it is not done by add_collection, as far as I can see. The axes methods for updating dataLim are: def update_datalim(self, xys): 'Update the data lim bbox with seq of xy tups' # if no data is set currently, the bbox will ignore it's # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata self.dataLim.update(xys, not self.has_data()) def update_datalim_numerix(self, x, y): 'Update the data lim bbox with seq of xy tups' # if no data is set currently, the bbox will ignore it's # limits and set the bound to be the bounds of the xydata. # Otherwise, it will compute the bounds of it's current data # and the data in xydata #print type(x), type(y) self.dataLim.update_numerix(x, y, not self.has_data()) Eric |