def axis_name(axis, axname):
    """
    Checks that an axis name is in ``{'x', 'y'}``. Raises an error on
    an invalid value. Returns the lower case verion of valid values.

    """

    valid_args = ['x', 'y']
    if axis.lower() not in valid_args:
        msg = 'Invalid value for {} ({}). Must be on of {}.'
        raise ValueError(msg.format(axname, axis, valid_args))

    return axis.lower()