class betagammaaxis(matplotlib.scale.ScaleBase):
    name = 'betagamma'

    def get_transform(self):
        return self.BetaGammaTransform()

    def set_default_locators_and_formatters(self, axis):
        def _high_formatter_func(x, pos):
            gamma = int(round(beta2gamma(x)))
            return "" if gamma % 2 == 0 else r'${}$'.format(gamma)

        axis.set_major_locator(matplotlib.ticker.FixedLocator(gamma2beta([7, 8, 9, 10, 11])))
        axis.set_major_formatter(matplotlib.ticker.FuncFormatter(_high_formatter_func))
        axis.set_minor_formatter(matplotlib.ticker.FuncFormatter(_high_formatter_func))

    class BetaGammaTransform(matplotlib.transforms.Transform):
        input_dims = 1
        output_dims = 1
        is_separable = True
        has_inverse = True

        def transform_non_affine(self, a):
            return beta2gamma(a)

        def inverted(self):
            return betagammaaxis.GammaBetaTransform()

    class GammaBetaTransform(matplotlib.transforms.Transform):
        input_dims = 1
        output_dims = 1
        is_separable = True
        has_inverse = True

        def transform_non_affine(self, a):
            return gamma2beta(a)

        def inverted(self):
            return betagammaaxis.BetaGammaTransform()


matplotlib.scale.register_scale(betagammaaxis)