From: John H. <jdh...@ac...> - 2006-02-01 18:48:33
|
>>>>> "Eric" == Eric Firing <ef...@ha...> writes: Eric> If this strategy sounds reasonable to you, I can go ahead Eric> and implement it. This looks fine; FYI I'll include a post I started in response to your earlier email but failed to push send; this provides a little context To: Eric Firing <ef...@ha...> Cc: Christopher Barker <Chr...@no...>, mat...@li... Subject: Re: [Matplotlib-users] Apparent bug in Data limits with LineCollections From: John Hunter <jdh...@ac...> Eric> I would like to make a genuine bugfix, but I do not yet Eric> understand all this well enough to do so right now. Maybe Eric> John will chime in with a good solution. Just a comment for now. If you look at ax.add_collection, it does not update the datalim. This is by design but it should be documented. The reason I didn't add it was collecitons were meant to be fast (they've failed a little bit on that front but they aren't mind-numbingly slow) and so I left it to the user to set the datalim manually since this is potentially expensive and the user often knows the lim for one reason or another. See the finance.py module for several instances on how to set the data lim with collections. Eg, minx, maxx = (0, len(rangeSegments)) miny = min([low for low in lows if low !=-1]) maxy = max([high for high in highs if high != -1]) corners = (minx, miny), (maxx, maxy) ax.update_datalim(corners) ax.autoscale_view() As for how the datalim handling works, the syntax is self.dataLim.update(xys, ignore) Note this is different than the ax.update_datalim method, which calls it. datalim is a bbox which has an ignore state variable (boolean). The ignore argument to update datalim can take on three values 0: do not ignore the current limits and update them with the xys 1: ignore the current datalim limits and override with xys -1: use the datalim ignore state to determine the ignore settings This seems a bit complex but arose from experience. Basically a lot of different objects want to add their data to the datalim. In most use cases, you want the first object to add data to ignore the current limits (which are just default values) and subsequent objects to add to the datalim taking into account the previous limits. The default behavior of datalim is to set ignore to 1, and after the first call with -1 set ignore to 0. Thus everyone can call with -1 and have the desired default behavior . I hope you are all confused now. One can manually set the ignore state var with datalim.ignore(1) Cheers, JDH |