On Tue, Jun 2, 2009 at 9:03 AM, Tom Vaughan <t...@software6.net> wrote: > Is it possible to add subplots to a figure if I don't know in advance > how many subplots I need to add? > > What I do now is I call add_subplot like add_subplot(i, 1, i) where i > is 1 initially, and just increases by 1 on each call. This almost > works. Except the first plot takes up the whole figure, the second > plot is placed on top of the bottom half of the first plot, etc. Is > there a way to "resize" the plots when a subplot is added? Or how > would I "re-plot" the previous subplots?
See the Axes.change_geometry command http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.SubplotBase.change_geometry As in this example:: import matplotlib.pyplot as plt # start with one fig = plt.figure() ax = fig.add_subplot(111) ax.plot([1,2,3]) # now later you get a new subplot; change the geometry of the existing n = len(fig.axes) for i in range(n): fig.axes[i].change_geometry(n+1, 1, i+1) # add the new ax = fig.add_subplot(n+1, 1, n+1) ax.plot([4,5,6]) plt.show() JDH > > Thanks. > > -Tom > > ------------------------------------------------------------------------------ > OpenSolaris 2009.06 is a cutting edge operating system for enterprises > looking to deploy the next generation of Solaris that includes the latest > innovations from Sun and the OpenSource community. Download a copy and > enjoy capabilities such as Networking, Storage and Virtualization. > Go to: http://p.sf.net/sfu/opensolaris-get > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ OpenSolaris 2009.06 is a cutting edge operating system for enterprises looking to deploy the next generation of Solaris that includes the latest innovations from Sun and the OpenSource community. Download a copy and enjoy capabilities such as Networking, Storage and Virtualization. Go to: http://p.sf.net/sfu/opensolaris-get _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users