On 08/12/2011 03:00 PM, Paul Ivanov wrote: > Christopher Brown, on 2011-08-12 16:56, wrote: >> I feel like I'm doing this right, but it doesn't work. Any clues? >> >> from matplotlib import pyplot as pp >> >> pp.plot((1,2,3)) >> ax = pp.gca() >> f = pp.figure(num=2) >> print 'first: %i' % ax.figure.number >> print 'second: %i' % f.number >> f.add_axes(ax) >> >> yields: >> >> Traceback (most recent call last): >> File "<stdin>", line 1, in<module> >> File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 606, >> in add_axes >> assert(a.get_figure() is self) >> AssertionError > > Right now, matplotlib allows an axes to participate in only one > figure. You can get part-way to what you want by setting > ax.figure=f before calling f.add_axes(ax). Then, you'll have ax > in both figures, but its transforms are still rooted in the first > figure, so resizing the first figure, you'll see changes to the > size of the plot in the second figure.
It's worse than that; it really just doesn't work in any useful way, and it was never intended to do so. Try it: In [1]: fig = gcf() In [2]: fig.add_axes? In [3]: plot([1,2,3]) Out[3]: [<matplotlib.lines.Line2D at 0x335cf10>] In [4]: ax = gca() In [5]: fig2 = figure() In [6]: ax.set_figure(fig2) In [7]: fig2.add_axes(ax) Out[7]: <matplotlib.axes.AxesSubplot at 0x333b250> In [8]: ax.plot([3,4,5]) Out[8]: [<matplotlib.lines.Line2D at 0x3368890>] In [9]: draw() Eric > > best, > > > > ------------------------------------------------------------------------------ > FREE DOWNLOAD - uberSVN with Social Coding for Subversion. > Subversion made easy with a complete admin console. Easy > to use, easy to manage, easy to install, easy to extend. > Get a Free download of the new open ALM Subversion platform now. > http://p.sf.net/sfu/wandisco-dev2dev > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ FREE DOWNLOAD - uberSVN with Social Coding for Subversion. Subversion made easy with a complete admin console. Easy to use, easy to manage, easy to install, easy to extend. Get a Free download of the new open ALM Subversion platform now. http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users