def despine_ax(ax=None):
    """
    Remove spines and ticks from a matplotlib axis

    Parameters
    ----------
    ax : matplotlib.axes.Axes object
        axes from which to remote spines and ticks. if None, do nothing

    Returns
    -------
    ax : matplotlib.axes.Axes object
        despined ax object
    """

    # Nothing real passed in.
    if ax is None:
        return None

    # remove spines
    ax.spines['right'].set_visible(False)
    ax.spines['left'].set_visible(False)
    ax.spines['top'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.set_xticks([])
    ax.set_yticks([])

    return ax