【发布时间】:2019-01-31 01:54:19
【问题描述】:
我绘制了一个条形图,我希望每个条形图都有一个学生姓名。 这是我的代码:
import matplotlib.pyplot
import numpy as np
names=["avi","jose","bob","nick","zelda","mark"]
pos=np.arange(6)+0.5
matplotlib.pyplot.bar(pos,(4,8,12,3,17,6),align="center",color="red")
matplotlib.pyplot.title("hight of students in unches",color="blue")
matplotlib.pyplot.xlabel("hight in inches",color="red")
matplotlib.pyplot.ylabel("students",color="red")
matplotlib.pyplot.tick_params(axis="x",color="white")
matplotlib.pyplot.tick_params(axis="y",color="white")
matplotlib.pyplot.yticks(pos,(names))
matplotlib.pyplot.show()
感谢您的帮助:)|
【问题讨论】:
-
因为您使用的是
matplotlib.pyplot.yticks(pos,(names)),所以您会在y轴上看到名称
标签: python matplotlib bar-chart