Not able to create plot with multi-index DataFrame

In this dataframe, there are multi index, I am unable to create plot with that. I am using plt.bar()
I want to create a plot such that for each type, there is a stacked bar plot of female and male. Any help?

image

ok so after unstacking it does create a plot using df.plot(kind = ‘bar’), but I want to create a plt.bar() plot, it doesn’t accepts multi index columns.
image

ok so this worked –

fig = plt.gcf();
fig.set_size_inches(15, 6);
plt.bar(df3.index, df3.Female, color = 'pink')
plt.bar(df3.index, df3.Male, bottom = df3.Female, color = 'blue')
plt.xticks(rotation = 90)
plt.tight_layout()
plt.show();

But if any other suggestion regarding this, pls let me know.

1 Like

For this code

df.plot(kind = 'bar')

The figure size attributes aren’t working.

fig = plt.gcf();

fig.set_size_inches(15,6);

df.unstack().plot(kind = 'bar');

plt.tight_layout();

plt.show();

'``

I tried the above code, but figure size is small only, for other plot types like plt.bar, this works.