From: Benjamin R. <ben...@ou...> - 2010-09-05 03:51:00
|
On Sat, Sep 4, 2010 at 3:20 AM, Jae-Joon Lee <lee...@gm...> wrote: > On Fri, Sep 3, 2010 at 4:14 AM, Benjamin Root <ben...@ou...> wrote: > > I think there are multiple issues here. Primarially, there is the issue > > that Axes3D is attaching itself to a figure. However, in the interest of > > backwards-compatibility, we can't just fix this outright. There is also > the > > issue that there are multiple places in the Figure class that are adding > > axes to the figure object. Ideally, shouldn't we have a single function > > that performs proper checks and adds an axes? Then that function should > be > > used in the other class functions to perform this action. In my opinion, > > there is too much duplicated code here. > > While I agree that we need to do something with the duplicated code, I > think our priority should be fixing a bug. > The easiest solution (that is backward compatible) seems to be > registering an Axes class that does not add itself to the figure. > For example, > > class Axes3DBase(Axes): > # All of the original Axes3D stuff, but do not add itself to the > figure during the initialization > > class Axes3D(Axes3DBase): > def __init__(self, ...) > Axes3DBase.__init__(self, ...) > self.fig.add_axes(self) > > # And register Axes3DBase instead of Axes3D > import matplotlib.projections as proj > proj.projection_registry.register(Axes3DBase) > > Regards, > > -JJ > Hmm, that actually would solve the problem at hand. What I am concerned about is having others use this as a way to solve other issues with Axes3D that we then can't get rid of it. My vote is that your approach be use as a last resort. I doubt this bug is time-critical, and I rather see the problems in Figure be correctly addressed. Ben Root |