October 2018
Beginner to intermediate
676 pages
18h 30m
English
The following code blocks plot two bar graphs for men and women. On the y axis, the average salary is plotted, and on the x axis, various groups are plotted within the men and women categories. So, we have a numeric variable on the y axis and a categorical variable on the x axis.
The following code block uses default settings for ticks and ticklabels on the y axis, but uses custom settings for the x axis:
menMue = [3, 10, 100, 500, 50]menSigma = [0.75, 2.5, 25, 125, 12.5]fig, ax = plt.subplots()ind = np.arange(len(menMue)) # the x locations for the groupswidth = 0.35 # the width of the barsp1 = ax.bar(ind, menMue, width, color='lightblue', bottom=0, yerr=menSigma)
Read now
Unlock full access