2024-04-23 10:26:51 发布
网友
我只想做一个柱状图,我可以自己画横坐标。在
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:未知属性勾选标签
您可能使用的是相当旧的Matplotlib版本(2015年11月之前)。tick_label参数是added to ^{} in 1.5.0和this commit。在
tick_label
更新到更新的版本(2.1现在是发布候选状态!)或者通过修改轴的记号标签手动重写记号。1.4及之前的示例here,节选如下:
# 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)
您可能使用的是相当旧的Matplotlib版本(2015年11月之前)。} in 1.5.0 和this commit。在
tick_label
参数是added to ^{更新到更新的版本(2.1现在是发布候选状态!)或者通过修改轴的记号标签手动重写记号。1.4及之前的示例here,节选如下:
相关问题 更多 >
编程相关推荐