Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python AttributeError:未知属性勾选标签_Python - Fatal编程技术网

Python AttributeError:未知属性勾选标签

Python AttributeError:未知属性勾选标签,python,Python,我只想做一个柱状图,我可以亲自做横坐标 import matplotlib.pyplot as plt heros=['Mage','Priest','Warlock'] y=[0.1828, 0.1300, 0.0689] x = range(len(heros)) plt.bar(range(len(y)), y,color=['g'],tick_label=heros) plt.show() 但我犯了个错误---- AttributeError:Unknown property tic

我只想做一个柱状图,我可以亲自做横坐标

import matplotlib.pyplot as plt
heros=['Mage','Priest','Warlock']
y=[0.1828, 0.1300, 0.0689]

x = range(len(heros))
plt.bar(range(len(y)), y,color=['g'],tick_label=heros)
plt.show()
但我犯了个错误----
AttributeError:Unknown property tick_label

您可能正在使用相当旧(2015年11月之前)的Matplotlib版本。
tick_label
参数为

更新到新版本(2.1现在是发行候选状态!),或者通过修改轴的记号标签手动重写记号。1.4和更早的示例,摘录如下:

# Example data
people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')
y_pos = np.arange(len(people))
performance = 3 + 10 * np.random.rand(len(people))

plt.barh(y_pos, performance, align='center', alpha=0.4)
plt.yticks(y_pos, people)
试一试


相反,这很有趣。我无法重现这个错误。您的代码在我的python解释器上运行良好。您使用的是哪一版本的python和matplotlib,以及您在何种环境下运行此版本(例如terminal、iPython等),可在python 2.7.10中复制;matplotlib.\uuuuu版本\uuuuuu'1.3.1'@使用什么版本的MPL降档?
    plot.xticks(x, heroes)