help with colorbar

Hello everyone,

I have a problem with a colorbar:
I have a stackedbar and a colorbar that I want to create or delete by clicking
on a button.. but when the colorbar is deleted I want to change the dimension
of the axes, resizing it even in the place occupied by the colorbar..
I need to create the colorbar by using the function "make_axes_locatable" and
not others function..

Someone can help me?

this is the code:

from matplotlib.figure import Figure
from mpl_toolkits.axes_grid.axes_divider import make_axes_locatable
from matplotlib import mpl, colorbar
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
from PyQt4.QtCore import *
from PyQt4.QtGui import *

import sys

class Test(QWidget):
    def __init__(self):
        self.resize(1000, 700)
        self.fig = Figure(figsize=(100,100), dpi=75)
        self.canvas = FigureCanvas(self.fig)
        self.axes = self.fig.add_subplot(111)
        b =[0,1,2,3],[5,4,9,6])
        self.colorbar = True
        self.old_size = self.axes.get_position()
        self.btn = QPushButton()
        self.Layout = QHBoxLayout()
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,

    def OnBtnClicked(self):
        self.colorbar = not self.colorbar

    def Colorbar(self):
        if self.colorbar :
            self.divider = make_axes_locatable(self.axes)
            self.cax = self.divider.append_axes("right", size="3%", pad=0.1)
            self.cmap = mpl.colors.ListedColormap(['b'])
            self.cb = mpl.colorbar.ColorbarBase(self.cax,
            if hasattr(self, "cb") :
                fig = self.axes.get_figure()
                del self.cb

app = QApplication(sys.argv)
win = Test()