4

is it possible to create a stacked barchart facetgrid with seaborn?

g = sns.FacetGrid(data, col="city", col_order=cities, col_wrap=3, height=5)
g = g.map(plt.plot, x="date", y="value", hue='time_bin', stacked=True, marker=".")

unfortunately does not work.

Fabian Bosler
  • 2,310
  • 2
  • 29
  • 49

1 Answers1

3

From what I can guess from your code, it can be done with plt:

fig, axes = plt.subplots(5,3,figsize=(12,20))
axes = axes.flatten()

for city,ax in zip(cities,axes):
    df = data[data.city==city].groupby(['date','time_bin']).value.count()
    df.unstack().plot.bar(ax=ax, stacked=True)

Output:

enter image description here

Quang Hoang
  • 146,074
  • 10
  • 56
  • 74