How to add a colorbar properly in python 2.7.2?
Question: I am affraid this sounds like a noobish question, but I am in trouble coding a
colorbar around my figures.

I took some time reading the documentation and these kind of examples :
colorbar(mappable, cax=None, ax=None, use_gridspec=True, **kw)

and I can not understand what is required to make it work. Mostly I obtain
this error : AttributeError: 'AxesSubplot' object has no attribute
'autoscale_None'

Lets think about details later on. What is the easiet/more simple way to pop a
colorbar along my fig which would auto scale I guess ( if it is the easiet
way). Or maybe should I previously determine the min and max of my values ?

Thanks for your help !

Here is the code (Only the figure 1 matters to me) and I am aware it is poorly
designed. The beginning is here to load data from previous files :

    
    
     from pylab import *
    import matplotlib.animation as animation
    
    from Tkinter import Tk 
    from tkFileDialog import askopenfilename
    
    Tk().withdraw() # we don't want a full GUI, so keep the root window from appearing
    filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
    
    with load(filename) as data:
        XYslice = data['XYslice']
        XZslice = data['XZslice']
        target = data['target']
        Over = data['Over']
        wvl=data['wvl']
        NA = data['NA']
        Dt = data['t']
        dz = data['dz']
    
    Ntime,N,Nplans=shape(XZslice)
    dxy=wvl/(2.0*NA)/Over 
    
    thebigone=max(XYslice[:,N/2,N/2])
    XZslice[0,0,0]=thebigone
    XYslice[0,0,0]=thebigone
    
    
    
    fig=figure(1,figsize=(12,6))
    ax1=fig.add_subplot(1,2,1)
    xlabel(r"$x (\mu m)$")
    ylabel(r"$y (\mu m)$")
    ax2=fig.add_subplot(1,2,2)
    xlabel(r"$x (\mu m)$")
    ylabel(r"$z (\mu m)$")
    
    I=zeros(shape(Dt))
    dI=zeros(shape(Dt))
    
    im1=ax1.imshow(XYslice[0,:,:],interpolation='none')#,extent=[-N*dxy/2.0,N*dxy/2.0,-N*dxy/2.0,N*dxy/2.0],cmap='hot')
    im2=ax2.imshow(XZslice[0,:,:],interpolation='none')#,extent=[-N*dxy/2.0,N*dxy/2.0,-Nplans*dz/2.0,Nplans*dz/2.0],cmap='hot')
    
    for ii in range(len(Dt)):
        zedata=float64(((XYslice[ii,:,:]**2)[where(target==1)]).reshape(-1))
        dI[ii]=(sqrt(var(zedata)))
        I[ii]=(mean(zedata))
    
    figure(2)
    subplot(121)
    plot(Dt,array(I),'o',Dt,array(dI))
    grid('on')
    subplot(122)
    #plot(Dt,array(dI)/array(I))
    xlabel('Dt ($\mu m^ 2$)')
    
    grid('on')
    
    #
    def init():
        im1.set_data(XYslice[0,:,:])
    
        im2.set_data(XZslice[0,:,:])
        return([im1,im2])
    
    def animate(t):
        im1.set_data(XYslice[t,:,:])
        im2.set_data(XZslice[t,:,:])
        return [im1,im2]
    
    ani = animation.FuncAnimation(fig, animate, np.arange(len(Dt)),interval=250,
                                  blit=True,init_func=init,repeat=True)
    
    show()    
    


Answer: Ok I find out how to do it ... It was really easy. I had to add
`colorbar(im2)` right after the definition of im2 ...

Have a good day !

