Answers for "Grouped bar chart with labels"

0

Grouped bar chart with labels

fig, ax = plt.subplots(figsize=(12, 8))
x = np.arange(len(df.job.unique()))

# Define bar width. We'll use this to offset the second bar.
bar_width = 0.4

# Note we add the `width` parameter now which sets the width of each bar.
b1 = ax.bar(x, df.loc[df['sex'] == 'men', 'count'],
            width=bar_width)
# Same thing, but offset the x by the width of the bar.
b2 = ax.bar(x + bar_width, df.loc[df['sex'] == 'women', 'count'],
            width=bar_width)
Posted by: Guest on November-19-2020

Code answers related to "Grouped bar chart with labels"

Python Answers by Framework

Browse Popular Code Answers by Language