class Myfmt(mpl.ticker.ScalarFormatter):

    def __call__(self, x, pos=None):
        rv = mpl.ticker.ScalarFormatter.__call__(self, x, pos)
if mpl.rcParams['text.usetex']:
    rv = re.sub('-', '\\mhyphen', rv)
matplotlib colorbar formatting