2014-09-25 108 views
1

说我绘制柱状图Matplotlib主要定位器:的柱状图中

from matplotlib.ticker import IndexLocator 
f , ax = plt.subplots(figsize=(10,5)) 
ax.bar(x, y, alpha=0.7, align='center') 

enter image description here

我怎样才能调整主要定位器的位置,这样我每有一个吧?

我试着用:

ax.xaxis.set_major_locator(IndexLocator(x)) 

,但我得到:

TypeError: __init__() missing 1 required positional argument: 'offset' 

不知道这是做正确的方式。

此外,为什么我的酒吧之间的间距关闭?

+0

没有看到x的值,不能在酒吧间距评论。 – mdurant 2014-09-25 20:44:55

回答

0

简单的答案:

plt.xticks(x) 
+0

'ax.set_xticks(x)',如果你使用像OP那样的面向对象的接口的话。 – 2014-09-25 20:47:43