grouped bar chart with labels

Solutions on MaxInterview for grouped bar chart with labels by the best coders in the world

showing results for - "grouped bar chart with labels"
Liah
20 Sep 2018
1fig, ax = plt.subplots(figsize=(12, 8))
2x = np.arange(len(df.job.unique()))
3
4# Define bar width. We'll use this to offset the second bar.
5bar_width = 0.4
6
7# Note we add the `width` parameter now which sets the width of each bar.
8b1 = ax.bar(x, df.loc[df['sex'] == 'men', 'count'],
9            width=bar_width)
10# Same thing, but offset the x by the width of the bar.
11b2 = ax.bar(x + bar_width, df.loc[df['sex'] == 'women', 'count'],
12            width=bar_width)
13