Connect a subplot from a figure to another in OO mode

I created an instance of Figure then add

    > some subplots to it.
    > Now i create another instance of Figure.
    > self.new_fig = Figure(figsize=(320,200),
    > dpi=80)

    > My aim is to add a Subplot instance to the
    > new Figure instance and changind the
    > number of rows and columns and the
    > position of the Subplot. I could have
    > done: self.new_fig.add_subplot(a)

The important thing to understand is that there is no concept of
"number of rows" of a figure, or "number of columns". The Subplot is
an instance of an Axes, and an Axes has a position property. The
position is left, bottom, width, height in fractional (0,1)
coordinates. When you say Subplot(111), matplotlib computes the
position but the figure does not have the property that it has one row
and one column. For example, you could do

ax1 = subplot(111)
ax2 = axes([0.8, 0.8, 0.15, 0.15])

and have another axes over the subplot. How many rows and columns
does the figure have? It's not particularly well defined, since it
has two axes, but not on a regular grid. Each figure maintains a list
of axes, and you can move them from one to another, and you can manage
their sizes in figure they live in with ax.get_position() and


If you want to set the position for a given subplot geometry (eg 211)
you can add the following method to axes.Subplot

    def change_geometry(self, numrows, numcols, num):
        'change subplot geometry, eg from 1,1,1 to 2,2,3'
        self._rows = rows
        self._cols = cols
        self._num = num

and call it like


You may want to make sure each axes instance you create has an unique
"label". The "current axes" machinery works by comaring the args and
kwargs you pass to add_axes. This is documented with an example in
the Figure.add_axes method.