def get_matrix(self):
    if self._invalid:
        limits_scaled = self._limits.transformed(self._scale_transform)
        yscale = (limits_scaled.ymax - limits_scaled.ymin)
        affine = Affine2D().scale((0.5 / yscale)).translate(0.5, 0.5)
        self._mtx = affine.get_matrix()
        self._inverted = None
        self._invalid = 0
    return self._mtx
def get_matrix(self):
    if self._invalid:
        limits_scaled = self._limits.transformed(self._scale_transform)
        yscale = (limits_scaled.ymax - limits_scaled.ymin)
        affine = Affine2D().scale((0.5 / yscale)).translate(0.5, 0.5)
        self._mtx = affine.get_matrix()
        self._inverted = None
        self._invalid = 0
    return self._mtx