'Helper function to locate the legend'

def _findoffset(self, width, height, xdescent, ydescent, renderer):

    if (self._loc == 0):
        (x, y) = self._find_best_position(width, height, renderer)
    elif (self._loc in Legend.codes.values()):
        bbox = Bbox.from_bounds(0, 0, width, height)
        (x, y) = self._get_anchored_bbox(self._loc, bbox, self.get_bbox_to_anchor(), renderer)
    else:
        (fx, fy) = self._loc
        bbox = self.get_bbox_to_anchor()
        (x, y) = ((bbox.x0 + (bbox.width * fx)), (bbox.y0 + (bbox.height * fy)))
    return ((x + xdescent), (y + ydescent))
