def colorbar_factory(cax, mappable, **kwargs):
 if (isinstance(mappable, contour.ContourSet) and any([(hatch is not None) for hatch in mappable.hatches])):
  cb = ColorbarPatch(cax, mappable, **kwargs)
 else:
  cb = Colorbar(cax, mappable, **kwargs)
 cid = mappable.callbacksSM.connect(u'changed', cb.on_mappable_changed)
 mappable.colorbar = cb
 mappable.colorbar_cid = cid
 return cb

def colorbar_factory ( cax , mappable , ** kwargs ) : if ( isinstance ( mappable , contour . ContourSet ) and any ( [ ( hatch is not None ) for hatch in mappable . hatches ] ) ) : cb = ColorbarPatch ( cax , mappable , ** kwargs ) else : cb = Colorbar ( cax , mappable , ** kwargs ) cid = mappable . callbacksSM . connect ( u'changed' , cb . on_mappable_changed ) mappable . colorbar = cb mappable . colorbar_cid = cid return cb
creates a colorbar on the given axes for the given mappable .