python读取excel绘图_python3.4读取excel数据绘图

1 #!/usr/bin/env python

2 #-*- coding:utf-8 -*-

3 #__author__ = "blzhu"

4 """

5 python study6 Date:20177 """

8 #coding=utf-8

9 #######################################################

10 #filename:xlrd_draw.py

11 #author:

12 #date:xxxx-xx-xx

13 #function:读excel文件中的数据

14 #######################################################

15 importnumpy as np16 importmatplotlib.pyplot as plt17 importxlrd18

19 #打开一个workbook

20 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 #定位到mySheet

27 mySheet = workbook.sheet_by_name(u'Pressure')28

29 #get datas

30 pressure =mySheet.col_values(0)31 print(pressure)32 time = mySheet.col(1)33 print('time1',time)34 time = [x.value for x intime]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 plot

43 fig = plt.figure(1)44

45 #plot pressure

46 plt.plot(time,pressure)47

48 plt.title('Barometer')49 plt.ylabel('Pa')50 plt.xticks(range(len(time)),time)51 plt.show()

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值