bugfix for dataLim problem (Chris Barker)


Chris Barker found a problem: plotting in an axes, then calling axes.cla, then adding a collection, then calling axes.plot, results in the original plot's dataLim being used as the starting point for the update. I think the problems are:

1) axes.add_line updates the data limits, but add_collection does not;

2) axes.has_data is simply looking to see whether a line or collection has been added, but is using that as an indication of whether the data limits have been set; this is invalid because add_collection does not set the limits.

I suggest two changes to address the problem:

1) Use a flag instead of the have_data() method to keep track of whether data limit updating needs to start from scratch. Then axes.cla() can set the flag, and the update_datalim* functions can clear it.

2) Add an optional flag to add_collection, telling it to call the collection's get_verts method and use the result to update the data limits. This would make it easier to use collections in user-level code, without imposing any performance penalty for functions like contour that handle the data limit updating in a more efficient way.

If this strategy sounds reasonable to you, I can go ahead and implement it.