Repository: matplotlib/matplotlib
File: lib/matplotlib/text.py (Python)

Code before:
                             for x, y, w in zip(xs, ys, ws)]

        # the corners of the unrotated bounding box
        corners_horiz = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]

        # now rotate the bbox
        rotation = self.get_rotation()
        rotate = functools.partial(_rotate_point, rotation)
        corners_rotated = [rotate(x, y) for x, y in corners_horiz]

        # compute the bounds of the rotated box
        xs, ys = zip(*corners_rotated)
        xmin, xmax = min(xs), max(xs)
        ymin, ymax = min(ys), max(ys)
        width = xmax - xmin
        height = ymax - ymin

        # Now move the box to the target position offset the display
        # bbox by alignment
        halign = self._horizontalalignment
        valign = self._verticalalignment

        rotation_mode = self.get_rotation_mode()
        if rotation_mode != "anchor":
            if rotation_mode == 'xtick':
                halign = self._ha_for_angle(rotation)
            elif rotation_mode == 'ytick':
                valign = self._va_for_angle(rotation)
            # compute the text location in display coords and the offsets
            # necessary to align the bbox with that location
            if halign == 'center':
                offsetx = (xmin + xmax) / 2
            elif halign == 'right':
                offsetx = xmax
            else:
                offsetx = xmin

            if valign == 'center':
                offsety = (ymin + ymax) / 2
            elif valign == 'top':
                offsety = ymax
            elif valign == 'baseline':
                offsety = ymin + descent
            elif valign == 'center_baseline':
                offsety = ymin + height - baseline / 2.0
            else:
                offsety = ymin
        else:
            xmin1, ymin1 = corners_horiz[0]
            xmax1, ymax1 = corners_horiz[2]


Review comment (suggestion):
I find this renaming unfortunate. Since we deal a lot with transformations `rotation` is quite ambiguous. I see that the change comes from `roation = self.get_rotation()`, on the lower level here `rotation` is too imprecise. I suggest either to stay with `angle` or be very explcit and switch to `rotation_angle`.

Code after:
        elif malign == 'right':
            offset_layout = [(x + width - w, y)
                             for x, y, w in zip(xs, ys, ws)]

        # the corners of the unrotated bounding box
        corners_horiz = [(xmin, ymin), (xmin, ymax), (xmax, ymax), (xmax, ymin)]

        # now rotate the bbox
        angle = self.get_rotation()
        rotate = functools.partial(_rotate_point, angle)
        corners_rotated = [rotate(x, y) for x, y in corners_horiz]

        # compute the bounds of the rotated box
        xs, ys = zip(*corners_rotated)
        xmin, xmax = min(xs), max(xs)
        ymin, ymax = min(ys), max(ys)
        width = xmax - xmin
        height = ymax - ymin

        # Now move the box to the target position offset the display
        # bbox by alignment
        halign = self._horizontalalignment
        valign = self._verticalalignment

        rotation_mode = self.get_rotation_mode()
        if rotation_mode != "anchor":
            if rotation_mode == 'xtick':
                halign = self._ha_for_angle(angle)
            elif rotation_mode == 'ytick':
                valign = self._va_for_angle(angle)
            # compute the text location in display coords and the offsets
            # necessary to align the bbox with that location
            if halign == 'center':
                offsetx = (xmin + xmax) / 2
            elif halign == 'right':
                offsetx = xmax
            else:
                offsetx = xmin

            if valign == 'center':
                offsety = (ymin + ymax) / 2
            elif valign == 'top':
                offsety = ymax
            elif valign == 'baseline':
                offsety = ymin + descent
            elif valign == 'center_baseline':
                offsety = ymin + height - baseline / 2.0
            else:
                offsety = ymin
        else:
            xmin1, ymin1 = corners_horiz[0]