def pandas_barplot(data, x, hue, y, x_order=None, hue_order=None, horizontal=True, stacked=True, **kwargs):
    """Create a barplot using pandas plot functionality

    Mainly allows for stacked barplots

    Parameters
    ----------
    data : DataFrame
        DataFrame with columns x and y
    x : str
        x defines the discrete variable that will be plotted on the x-axis.
    hue : str
        hue defines the variable that will separate variables with the same x value.
    y: str
        y is the continuous variable defining the height of each bar
    x_order: list, optional
        order of x axis
    hue_order: list, optional
        order of colors
    horizontal: bool, optional
        whether to lay the bar plot out horizontally
    stacked: bool, optional
        whether to stack barplots
    **kwargs
        passed on to Pandas' plot function or matplotlib's bar function

    Returns
    -------
    matplotlib.axes.Axes
    """
    spread_data = data.pivot(index=x, columns=hue, values=y)
    if x_order is not None:
        spread_data = spread_data.reindex(index=x_order)
    if hue_order is not None:
        spread_data = spread_data[hue_order]
    if horizontal:
        ax = spread_data.plot.barh(stacked=stacked, **kwargs)
    else:  # vertical
        ax = spread_data.plot.bar(stacked=stacked, **kwargs)
    return ax