没有合适的资源?快使用搜索试试~ 我知道了~
首页python读取excel数据绘制简单曲线图的完整步骤记录
python读写excel文件有很多种方法: 用xlrd和xlwt进行excel读写 用openpyxl进行excel读写 用pandas进行excel读写 本文使用xlrd读取excel文件(xls,sxls格式),使用xlwt向excel写入数据 一、xlrd和xlwt的安装 安装很简单,windos+r调出运行窗口,输入cmd,进入命令行窗口,输入以下命令。 安装xlrd: pip install xlrd 安装xlwt: pip install xlwt xlrd的API(application programming interface)网址: https://x
资源详情
资源评论
资源推荐

python读取读取excel数据绘制简单曲线图的完整步骤记录数据绘制简单曲线图的完整步骤记录
python读写读写excel文件有很多种方法:文件有很多种方法:
用xlrd和xlwt进行excel读写
用openpyxl进行excel读写
用pandas进行excel读写
本文使用xlrd读取excel文件(xls,sxls格式),使用xlwt向excel写入数据
一、一、xlrd和和xlwt的安装的安装
安装很简单,windos+r调出运行窗口,输入cmd,进入命令行窗口,输入以下命令。
安装xlrd: pip install xlrd
安装xlwt: pip install xlwt
xlrd的API(application programming interface)网址: https://xlrd.readthedocs.io/en/latest/api.html
在这里可以看到xlrd内的各种对象和方法
数据读取数据读取
用xlrd读取excle数据:
使用xlrd.open_wokrbook(),打开文件,得到book对象
book.sheet()[0]得到sheet对象
基于sheet对象获取各种信息,(往下还有cell对象)
import numpy as np
from matplotlib import pyplot as plt
import chinese
import xlrd
import xlwt
#导入了chinese.py来设置汉字,
chinese.set_ch()
"""读取excel文件,API见https://xlrd.readthedocs.io/en/latest/api.html"""
filename='wind.xls'
book_wind=xlrd.open_workbook(filename=filename)
wind_sheet1=book_wind.sheets()[0] #这个[0]我没看懂
#读取第1行标题
title=wind_sheet1.row_values(0)
#读取第一、二、三列标题以下的数据 col_values(colx,start_row=0,end_row=none)
x=wind_sheet1.col_values(0,1)
y1=wind_sheet1.col_values(1,1)
y2=wind_sheet1.col_values(2,1)
#绘制曲线图
line1,=plt.plot(x,y1,label='速度场方差')
line1.set_dashes([2,2,10,2]) #将曲线设置为点划线,set_dashes([line_space,space_space,line_space,space_space])
line2,=plt.plot(x,y2,label='流量场方差')
line2.set_dashes([2,2,2,2])
plt.title('方差曲线',fontsize=16)
plt.legend(loc=4) #设置图例位置,4表示右下角
plt.show()
总结总结
您可能感兴趣的文章您可能感兴趣的文章:PYTHON如何读取和写入EXCEL里面的数据python读取Excel表格文件的方法python3读取excel文件只
提取某些行某些列的值方法Python读取Excel表格,并同时画折线图和柱状图的方法python 实现读取一个excel多个sheet表并合
并的方法Python实现读取txt文件并转换为excel的方法示例python实现读取excel文件中所有sheet操作示例Python从Excel中读
取日期一列的方法Python导出数据到Excel可读取的CSV文件的方法python实战之实现excel读取、统计、写入的示例讲解



















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0