Is there an easy way to change the subplot orders

Hi,

I am new to matplotlib. Currently I have a need to change the subplot
orders after the subplts have been added to a figure. I haven't found a
way to do it easily. One of my solution is to keep an ordered list of
the subplots and re-add them in the correct order. But this way, all the
navigation information (zoom/pan) is lost. Another way I found is to
get the positions (get_position method of Axes) of the subplot and
then set the positions according to the new order, which is quite
cumbersom. I am thinking if there is a similar method like add_subplot
(that is, accepting new positional information of row, column, number
instead of Bbox), it will be great. Does anyone know any better
solution?

Also related to this, I need to add a subplot using the add_subplot
method of the Figure class, and update the previously added subplots
accordingly. For example, I add a subplot using add_subplot(1, 1, 1).
Then later, I need to add another subplot. The new layout should be
the first plot being 211, the second one being 212. How do I change
the first plot from 111 to 211? I haven't found a way other than re-add
the plots. Can some one shed some light on me please?

Thanks

Kun

It should work to call ax.change_geometry on the existing subplot instances.

  http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.SubplotBase.change_geometry

Haven't tested it for this use case, but I'm pretty sure it will do
what you want. Let me know!

JDH

···

On Tue, Jul 28, 2009 at 10:27 PM, Kun Hong<kun.hong@...2707...> wrote:

Hi,

I am new to matplotlib. Currently I have a need to change the subplot
orders after the subplts have been added to a figure. I haven't found a
way to do it easily. One of my solution is to keep an ordered list of
the subplots and re-add them in the correct order. But this way, all the
navigation information (zoom/pan) is lost. Another way I found is to
get the positions (get_position method of Axes) of the subplot and
then set the positions according to the new order, which is quite
cumbersom. I am thinking if there is a similar method like add_subplot
(that is, accepting new positional information of row, column, number
instead of Bbox), it will be great. Does anyone know any better
solution?