Possible to draw grouped bar plot in plotly-express

I am very excited about plotly-express, especially its simple user interface to draw multiple bar plot. However, in my own day-to-day analysis, I use the grouped bar plot a lot. I use it primary to compare different brands spending in several media channels, here is what I have in mind:

I wrote my own script group bar plot like this:

def group_bar_plot(dataframe, x, y, group, **kwargs):
    items = dataframe[group].unique()
    data = []
    for item in items:
        group_item = dataframe[dataframe[group]==item]
        data.append(
            go.Bar(
                x = group_item[x],
                y = group_item[y],
                name = str(item)
            ) 
        )
    layout = go.Layout(barmode='group')
    layout.update(kwargs)
    fig = go.Figure(data=data, layout=layout)
    iplot(fig)

My questions is:

  1. Can I do the same thing use plotly-express?
  2. If not, how hard it is to write an additional feature like adding barmode=β€˜grouped’ into px.bar, in case I have some free time and I want to contribute.

Thanks in advance for any help.
Mike

Hi! I just pushed up version 0.1.5 of Plotly Express which includes barmode for px.bar() … This has been blocked for a couple of weeks (until this morning!) on a bugfix that needed to percolate through our release pipeline.

1 Like