def _checkimagearg(x, y, im):
    """x and y can be arrays or single-item dicts
    (each dict comprises an axis name (or tuple of axis name/position) and array (can be None))
    """
    if x is not None:
        if isinstance(x, dict):
            x = list(x.values())[0]
        if x is not None and x.shape[0] != im.shape[1]:
            raise AttributeError(
                'Width of image does not match the length of x')
    if y is not None:
        if isinstance(y, dict):
            y = list(y.values())[0]
        if y is not None and y.shape[0] != im.shape[0]:
            raise AttributeError(
                'Height of image does not match the length of y')
