Hi,
I've got a situation where I'd like to create several instances of Axes
but not set their position until later. It seems I have to jump through
hoops to actually create a new axes, contrary to my expectation:
$ ipython -pylab
In [1]: a=axes()
In [2]: a
Out[2]: <matplotlib.axes.Subplot instance at 0x2aaab158a758>
In [3]: b=axes()
In [4]: b
Out[4]: <matplotlib.axes.Subplot instance at 0x2aaab158a758>
I can see what's happening here:
1. pylab.axes() calls subplot(111) when no arguments are given.
2. subplot(111) uses some smarts to figure out if an Axes instance for
subplot(111) has already been given and, if so, returns a reference to that.
Both points 1 and 2 seem reasonable on their own, but when combined, as
in my example, the outcome is not intuitive. Is this behavior desired?
Does anyone depend on it?
It goes deeper -- even Figure.add_axes() returns an old Axes instance if
the rect given has been seen before. I'd argue that people delving into
the OO innards of matplotlib should be able to handle keeping a
reference to instances of Axes they've created. Can we change this
behavior or would it cause massive breakage somewhere?
Cheers!
Andrew