python读取excel绘图_python读取excel数据绘图的实例详解

1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # __author__ = "blzhu" 4 """ 5 python study 6 Date:2017 7 """ 8 # coding=utf-8 9 #######################################################10 # filename:xlrd_draw.py11 # author:12 # date:xxxx-xx-xx13 # function:读excel文件中的数据14 #######################################################15 import numpy as np16 import matplotlib.pyplot as plt17 import xlrd18 19 # 打开一个workbook20 workbook = xlrd.open_workbook(r'E:\python\pycharmwork\test\matplotlibzbl\Barometer.xlsx')21 22 # 抓取所有sheet页的名称23 worksheets = workbook.sheet_names()24 print('worksheets is %s' % worksheets)25 26 # 定位到mySheet27 mySheet = workbook.sheet_by_name(u'Pressure')28 29 # get datas30 pressure = mySheet.col_values(0)31 print(pressure)32 time = mySheet.col(1)33 print('time1',time)34 time = [x.value for x in time]35 print('time2',time)36 37 38 # drop the 1st line of the data, which is the name of the data.39 pressure.pop(0)40 time.pop(0)41 42 # declare a figure object to plot43 fig = plt.figure(1)44 45 # plot pressure46 plt.plot(time,pressure)47 48 plt.title('Barometer')49 plt.ylabel('Pa')50 plt.xticks(range(len(time)),time)51 plt.show()

f04ac46506464adcf758e5eae1ea8e65-0.png

c6749940da08f86a8bbdc5108aa398c2-1.png

参考:

学习python好去处:

以上就是python读取excel数据绘图的实例详解的详细内容,更多请关注php中文网其它相关文章!

article_wechat2021.jpg?1111

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值