import math


def _calculate_label_rotation(startx, starty, endx, endy):
    """
    Calculates the appropriate rotation angle for a label on an arrow (matches line, is between -90 and 90 degrees)

    :param startx: start of arrow (x)
    :param starty: start of arrow (y)
    :param endx: end of arrow (x)
    :param endy: end of arrow (y)

    :return: rotation angle.
    """
    return math.degrees(math.atan((endy - starty)/(endx - startx)))