def _process_2D_plot_args(args, gridding_dz=1):
    """
    Processes input to the plotting class functions. Allows plots to receive
    one (2D) or three (1D) input arguements.
    """
    from numpy import array, ma, nan, ndarray
    from pandas import DataFrame, Series
    from xarray import DataArray
    from .mapping import grid_data
    from .helpers import GliderToolsError
    name = ''
    if len(args) == 3:
        x = array(args[0])
        y = array(args[1]).astype(float)
        z = args[2].copy()
        if isinstance(z, ma.MaskedArray):
            z[z.mask] = nan
        elif isinstance(z, DataArray):
            name = z.name if z.name is not None else ''
            unit = ' [{}]'.format(z.units) if 'units' in z.attrs else ''
            name = name + unit
            z = ma.masked_invalid(array(z)).astype(float)
        else:
            z = ma.masked_invalid(array(z)).astype(float)
        if (x.size == y.size) & (len(z.shape) == 1):
            df = grid_data(x, y, z, interp_lim=6, verbose=False,
                return_xarray=False)
            x = df.columns
            y = df.index
            z = ma.masked_invalid(df.values)
        return x, y, z, name
    elif len(args) == 1:
        z = args[0]
        if isinstance(z, DataArray):
            name = z.name if z.name is not None else ''
            unit = ' [{}]'.format(z.units) if 'units' in z.attrs else ''
            name = name + unit
            if z.ndim == 1:
                raise GliderToolsError(
                    'Please provide gridded DataArray or x and y coordinates')
            elif z.ndim == 2:
                z = z.to_series().unstack()
            elif z.ndim > 2:
                raise GliderToolsError(
                    'GliderTools plotting currently only supports 2 dimensional plotting'
                    )
        elif isinstance(z, (ndarray, Series)):
            if z.ndim == 2:
                z = DataFrame(z)
            else:
                raise IndexError('The input must be a 2D DataFrame or ndarray')
        x = z.columns.values
        y = z.index.values
        z = ma.masked_invalid(z.values).astype(float)
        return x, y, z, name
