From: John H. <jdh...@ac...> - 2004-12-21 23:43:01
|
In thinking about Michel Sanner's problem of removing subplots, I decided to make some changes in the way axes and subplot management was done by the backends and the pylab interface. The problem was that there was a chain of calls from the FigureManager for adding subplots and axes to the Figure, and this was done so the FigureManager could manage the current axes. The other reason it was designed this way is the figure manager need to be notified whenever the number of axes changed, so it could update the classic toolbar menu. The problem with this design is that every time I wanted to add a new kwarg or some other feature to add_axes or add_subplot in the Figure, these changes had to be mirrored in the FigureManager, sometimes across backends which had concrete implementations, which proved to be a pain. And when I wanted to think about deleting axes, I had to worry about the FigureManager's information and the figure's information, which was a bad design. In its place, I added the management of the current axes to the Figure class itself, and used an observer pattern so the backend FigureManager could get notification when the number of axes changed. So FigureManager add_subplot and add_axes methods no longer exist. Note the Figure doesn't *do* anything with the current axes information, it merely manages it. As my Christmas present to the backend maintainers, I ported these changes to WX, GTK, Tk and FLTK. I don't have FLTK on my system so Gregory please test. I have run the other backends through backend_driver.py and have done some interactive testing as well and everything looks good. But please update from CVS after giving the mirrors a few hours and test for yourself. Ted, please make sure your QT implementer is advised of these changes. There is also a new method Figure.delaxes and a pylab interface function delaxes to remove an axes from the Figure. This is different from merely clearing an axes with cla, and the Figure updates the current axes after a call to delaxes using an axes stack so the previously current axes becomes current after a deletion. Eg, from pylab import * ax1 = subplot(211) plot([9,10,11]) ylabel('y1') ax2 = subplot(212) scatter(rand(10), rand(10)) ylabel('y2') subplot(211) # make 211 current title('this is a title', color='r') grid() delaxes(ax1) # now 212 is current again grid() Thanks, JDH |