柱状图(bar)
1 柱状图绘制
需求1-对比每部电影的票房收入
电影数据如下图所示:
1 准备数据
['雷神3:诸神黄昏','正义联盟','东方快车谋杀案','寻梦环游记','全球风暴', '降魔传','追捕','七十七天','密战','狂兽','其它']
[73853,57767,22354,15969,14839,8725,8716,8318,7916,6764,52222]
2 绘制matplotlib.pyplot.bar(x, width, align='center', **kwargs)
绘制柱状图
Parameters:
x : sequence of scalars.
width : scalar or array-like, optional
柱状图的宽度
align : {‘center’, ‘edge’}, optional, default: ‘center’
Alignment of the bars to the x coordinates:
‘center’: Center the base on the x positions.
‘edge’: Align the left edges of the bars with the x positions.
每个柱状图的位置对齐方式
**kwargs :
color:选择柱状图的颜色
Returns:
`.BarContain