def colorbar(mappable, cax=None, ax=None, **kw):
 import matplotlib.pyplot as plt
 if (ax is None):
  ax = plt.gca()
 if (cax is None):
  (cax, kw) = make_axes(ax, **kw)
 cax._hold = True
 cb = Colorbar(cax, mappable, **kw)
 def on_changed(m):
  cb.set_cmap(m.get_cmap())
  cb.set_clim(m.get_clim())
  cb.update_bruteforce(m)
 cbid = mappable.callbacksSM.connect(u'changed', on_changed)
 mappable.colorbar = cb
 ax.figure.sca(ax)
 return cb

def colorbar ( mappable , cax = None , ax = None , ** kw ) : import matplotlib . pyplot as plt if ( ax is None ) : ax = plt . gca ( ) if ( cax is None ) : ( cax , kw ) = make_axes ( ax , ** kw ) cax . _hold = True cb = Colorbar ( cax , mappable , ** kw ) def on_changed ( m ) : cb . set_cmap ( m . get_cmap ( ) ) cb . set_clim ( m . get_clim ( ) ) cb . update_bruteforce ( m ) cbid = mappable . callbacksSM . connect ( u'changed' , on_changed ) mappable . colorbar = cb ax . figure . sca ( ax ) return cb
create a colorbar for a scalarmappable instance .