如何固定条形图条形图的左位置?

时间:2018-11-09 14:12:36

标签: python matplotlib

这是我的代码:

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()

This是它生成的vs我尝试复制的this one的条形图。我的第一个条形图在[0]位置上-为什么它不与y轴齐平?

0 个答案:

没有答案