0

I have a Matplotlib stacked bar plot -

df.groupby(['date', 'flavor'])['minutes'].sum().unstack().plot(kind='bar', stacked=True)

I would like to convert this to an interactive plot using interact from ipywidgets. But, when I try this -

@interact
df.groupby(['date', 'flavor'])['minutes'].sum().unstack().iplot(kind='bar', stacked=True)

It gives me an Exception: Invalid keyword : 'stacked'. Can someone tell me the right syntax for this kind of interactive chart with ipywidgets?

Thanks!

harry04
  • 900
  • 2
  • 9
  • 21
  • Try using %matplotlib notebook, this activates nbagg backend which enables interactivity see this: https://matplotlib.org/3.1.0/users/prev_whats_new/whats_new_1.4.html#the-nbagg-backend – Ankit Agrawal Jul 08 '19 at 08:04

1 Answers1

0

I found it! It's an attribute called barmode. So, it can used as -

@interact
df.groupby(['date', 'flavor'])['minutes'].sum().unstack().iplot(kind='bar', barmode='stack')
harry04
  • 900
  • 2
  • 9
  • 21