From: Christopher B. <Chr...@no...> - 2006-02-01 00:44:18
|
Christopher Barker wrote: > Maybe I'll try to make a small sample that demonstrates the issue. stay > tuned. OK, read the previous posts for background, or ignore them, and just read this one. I made a small sample, and found that using a LineCollection with axes.add_collection does something weird to the data limits that axes sets. I've enclosed a small sample that demonstrates the problem. Here is the plotting code itself: # Do some plotting ax.plot(offsets[:,0], offsets[:,1], 'o') # clear the axes, and try again, with different data. ax.clear() offsets *= .1 coll = LineCollection(segments, offsets=offsets, transOffset=ax.transData, # transforms the x,y offsets ) # points/72.*dpi = pixels -- see matplotlib.transforms trans = scale_transform(fig.dpi/Value(72.), fig.dpi/Value(72.)) coll.set_transform(trans) # the points to pixels transform ax.add_collection(coll) ax.plot(offsets[:,0], offsets[:,1], 'o') ax.autoscale_view() pylab.show() running this, you get the axes set to data limits appropriate to the first ax.plot call, before the ax.clear() call. (the second has values 1/10 as large. However, if you don't do the first plot call, it all scales correctly. Now it's even weirder. If you do the first plot call (with the larger data), but comment out add_collection() call, it scales correctly. So it seems that using add_collection someone fixes the data limits to the previous value, even after the ax.clear() call. AFAICT, looking at the axes class code, this shouldn't happen. add_collection doesn't do much at all. Also, after axes.clear() is called, ax.has_data() returns False, so when axes.update_datalim is called, the old dataLim should be ignored. by the way, it looks like axes.cla() should perhaps have this in it: self.dataLim = unit_bbox() or maybe: self._set_lim_and_transforms() I've gotten a bit lost in all this: HELP! -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |