def _set_label_positions(location, rotation):
    """Get rotation, horizontal alignment, and vertical alignment, 
    respectively, based on orientation and rotation
    """
    if location in ['top', 'bottom']:
        rotation = 'horizontal' if rotation is None else rotation
        return rotation, 'right', 'center'
    
    elif location in ['left', 'right']:
        rotation = 90 if rotation is None else rotation
        if rotation == 90 or rotation == 0:
            return rotation, 'center', 'bottom'
        else:
            return rotation, 'left', 'bottom'
    else:
        raise ValueError("`location` must be 'top', 'bottom', 'left' or "
                         "'right'")