1、介绍

bar与barh均为画柱状图所用函数

2、函数介绍

2.1 matplot.pyplot.bar(水平柱状图)

(2)Matplotlib_bar, barh_柱状图

params:
y:放两个列表进去

第一个是多少给索引,
第二个是每个索引对应的数值是多少
width:每个柱的长度((固定的情况下该参数不能修改))
height:每个柱的宽度(height与width概念有一点混)
left:横轴的数字的标准化,默认是0
align:对其方式,‘center’, ‘edge’

2.2 matplot.pyplot.bar(竖直柱状图)

(2)Matplotlib_bar, barh_python_02

params:
参数与barh类似,唯一不同的是
width:每个柱的宽度
height:每个柱的高度(固定的情况下该参数不能修改)

3、例子

pyplot.bar(range(5), [gradeGroup.get(xtick) for xtick in xticks], align='center')
#其中gradeGroup为字典,内容如下
#{'A': 681, 'B': 1664, 'C': 2543, 'D': 2528, 'E': 2584}

4、效果

4.1 bar

(2)Matplotlib_bar, barh_柱状图_03

4.2 barh

(2)Matplotlib_bar, barh_柱状图_04