这是我的代码:
import matplotlib.pyplot as figure
menMeanHeight = [65, 60, 62, 55, 72]
menStdError = [2.1, 3.0, 4.5, 1.3, 2.2]
dataLst = menMeanHeight
y_errorLst = menStdError
n = len(menMeanHeight)
leftPos = range(0, n)
barWidth = 0.3
figure.bar(leftPos, dataLst, width=barWidth, color = "b", yerr = y_errorLst)
figure.title("Average Heights of Men by Group", size = 22)
figure.ylabel("Height (inches)", size = 16)
figure.xlabel("Group", size = 16)
xLabelLoc = [i + (barWidth/2) for i in leftPos] # should label under each bar if they were positioned right
xAxisLabels = ["G%s" % num for num in range(1,n+1)]
figure.xticks(xLabelLoc, xAxisLabels)
figure.show()