Hi everyone,

I'm getting in trouble trying to delete a couple of subaxes from my canvas.
The problem is shown by the example script below:

from matplotlib.figure import Figure
from mpl_toolkits.axes_grid.axes_divider import make_axes_locatable
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys

class Test(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        self.resize(1000, 600)  
        self.fig = Figure(figsize=(100,100), dpi=75)  
        axes1 = self.fig.add_subplot(121)
        axes2 = self.fig.add_subplot(122)

        self.subaxes = []
        for ax in [axes1, axes2]:
            self.divider = make_axes_locatable(ax)
            self.subaxes.append(self.divider.append_axes("right", "40%",
"20%"))
        
        b = QPushButton("Remove subaxes")
        b.clicked.connect(self.OnBtnClicked)
        l = QHBoxLayout()
        l.addWidget(FigureCanvas(self.fig))
        l.addWidget(b)
        self.setLayout(l)

    def OnBtnClicked(self):
        for sa in self.subaxes:
            self.fig.delaxes(sa)
            del sa
        self.fig.canvas.draw()

app = QApplication(sys.argv)
win = Test()
win.show()
sys.exit(app.exec_())


The main window is made up of two main axes an two subaxes placed on their
right side. If you click the button in the window, the two subaxes disappear
as I expect, but the orignal axes don't resize. Is there something I am
missing? Or can anyone point me out if there is a better way to achieve
this?

Thanks in advance!



--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Subaxes-deletion-issue-tp40268.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to