python绘图文件,循环遍历文件并绘图(Python)

这篇博客介绍如何使用Python循环遍历文本文件并进行绘图。首先删除每份文件的第一行(变量名),然后使用numpy的genfromtxt读取数据,分别绘制T%与WL以及ABS与WL的关系图。通过glob模块遍历当前目录下所有.txt文件,并使用matplotlib进行展示。
摘要由CSDN通过智能技术生成

My data is look like as in the picture. All of my datas are in .txt format and my aim is to loop over files and plot them. First row represents my variables

(WL, ABS, T%) so firstly I need to delete them before proceeding.

with open('Desktop/100-3.txt', 'r') as f:

data = f.read().splitlines(True)

with open('Desktop/100-3.txt', 'w') as f:

f.writelines(data[1:])

Probably it would not be necessary but I am very new in Numpy. Basically the algorithm will be as follows:

Read all the .txt files

Plot T% versus WL, plot ABS versus WL, save. (WL -> x variable)

Continue for the next file, .. (two graphs for every .txt file)

Then finish the loop, exit.

What I've tried

from numpy import loadtxt

import os

dizin = os.listdir(os.getcwd())

for

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值