首页 > 其他 > 详细

柱状图

时间:2018-01-20 22:09:58      阅读:335      评论:0      收藏:0      [点我收藏+]
问题1:
for m, n in zip(x1, y1):
plt.text(m + 0.08, n + 20, ‘%.2f‘ % n, ha=‘center‘, va=‘bottom‘)

for m, n in zip(x2, y2):
plt.text(m - 0.08, n + 10, ‘%.2f‘ % n, ha=‘center‘, va=‘bottom‘)
问题2:
如果是三个图怎么办

0.5:柱状图的宽度
align:对齐方式
x1=[1,2,3]
x2=[1,2,3]
y1=[600,700,800]
y2=[500,900,1000]

plt.figure()
plt.bar(x1,y1,0.1,color=y,align=edge,label=进口 单位/美元)
plt.bar(x2,y2,-0.1,color=r,align=edge,label=出口 单位/美元)

for m, n in zip(x1, y1):
    plt.text(m + 0.08, n + 20, %.2f % n, ha=center, va=bottom)

for m, n in zip(x2, y2):
    plt.text(m - 0.08, n + 10, %.2f % n, ha=center, va=bottom)

plt.xlabel(第一季度/月)
plt.ylabel(进出口额/美元)
plt.title(第一季度进出口数据)
plt.xticks(range(1,4),[str(i)+ for i in range(1,4)])
plt.legend()
plt.show()

技术分享图片

 

 

 

adding

1.按到Insert会出现想命令行一样的输入形式

2.打开ipynb文件,将文件移到jupyter下就可以打开了

柱状图

原文:https://www.cnblogs.com/jad-xxd/p/8322023.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!