Hi,
I am new to plotly. I am trying to do a bar plot with bars grouped side-by side. Using the python and plotly express bar
, the argument barmode='group'
has no effect and the bar are stacked instead. Here is the code:
fig = px.bar(df_, x='model_name', y='num_items', color='model_cycle', barmode='group')
Output:
For completeness, here is the DataFrame:
dd = {'model_name': {0: 1,
1: 5,
2: 5,
3: 6,
4: 2,
5: 2,
6: 2,
7: 2,
8: 4,
9: 4,
10: 0,
11: 3,
12: 3,
13: 3},
'model_cycle': {0: 1,
1: 1,
2: 2,
3: 1,
4: 1,
5: 2,
6: 3,
7: 4,
8: 1,
9: 2,
10: 1,
11: 1,
12: 2,
13: 3},
'num_items': {0: 2804,
1: 1966,
2: 5835,
3: 1034,
4: 900,
5: 7,
6: 1973,
7: 2108,
8: 416,
9: 1137,
10: 285,
11: 1808,
12: 4817,
13: 2835}}
df_ = pd.DataFrame.from_dict(dd)