On 2012/09/23 9:27 AM, Benjamin Root wrote: > > > On Sunday, September 23, 2012, Giovanni Plantageneto wrote: > > Hi everybody, > sorry, I guess the question is trivial, but I confess my matplotlib > and python ignorance. > > I'm running some code written by someone else, and apparently some > bits of the code are not compliant with newer versions of matplotlib. > So, how can I rewrite the following, which give AttributError? > > > self.ax.get_figure().axes = [] > > and > > > self.ax.get_figure().axes = [self.ax <http://self.ax>] > > Thanks a lot. > > > Without context, it would be hard to say. What was the exception > message? I bet it was a NoneType object being returned by get_figure(), > which would mean that the Axes object was created without a figure, > which is rarely done.
It looks to me like the code was trying to delete all axes but one from the figure. This probably worked when Figure.axes was a plain list, but for quite some time it has been a read-only list generated from an AxesStack instance. The code will need rewriting based on an understanding of what it is trying to do, and how mpl works now. There is no shortcut. For this particular problem, you might be able to do something like this: fig = self.ax.get_figure() axlist = fig.axes for ax in axlist: if not ax == self.ax: fig.delaxes(ax) Eric > > Also, it looks like the code was trying to manage the hierarchy of > objects itself (maybe the code was trying to detach an axes from one > figure and transfer to another? Lots of bookkeeping code like this is > not needed, but you may still have other issues lurking. > > Ben Root > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://ad.doubleclick.net/clk;258768047;13503038;j? > http://info.appdynamics.com/FreeJavaPerformanceDownload.html > > > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ------------------------------------------------------------------------------ Everyone hates slow websites. So do we. Make your web apps faster with AppDynamics Download AppDynamics Lite for free today: http://ad.doubleclick.net/clk;258768047;13503038;j? http://info.appdynamics.com/FreeJavaPerformanceDownload.html _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users