From: Eric F. <ef...@ha...> - 2006-02-01 08:36:31
|
Christopher Barker wrote: > 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. Chris, Attached is a slight modification of your test case, with annotations. I think it does what you want--sort of. But I agree that there is a bug. After chasing references backwards and forwards through axes.py, axis.py, ticker.py, and _transforms.cpp, I don't quite understand how everything works, but I think this is part of the problem: axes.has_data() is being used to determine whether to update the dataLim from scratch, or to start with previous values. axes.has_data() is True if any drawing artist (Line, Collection, etc.) has been added to the axes. So, after clearing the axes, adding a LineCollection tells the dataLim update method (called by the subsequent plot()) to use the old information, even though Collections (unlike Lines) do not change the dataLim. In other words, in your original script, I think that adding the collection was preventing plot() from setting the axes to a smaller value. Workarounds: either set the dataLim explicitly, or add the collection after the plot command (as in the attached modified script). The latter only works if the plot command sets the dataLim to be large enough to cover everything in the collection. I would like to make a genuine bugfix, but I do not yet understand all this well enough to do so right now. Maybe John will chime in with a good solution. Eric |