import os import glob import pandas as pd import numpy as np import matplotlib import matplotlib.pyplot as plt import japanize_matplotlib as jpplt folderpath = os.getcwd() filepathes = glob.glob(folderpath + "/*.txt") def grf_scope(x_data,y_data): xmax= x_data.max() xmin= x_data.min() ymax= y_data.max() ymin= y_data.min() x_lim_min = xmin - (xmax-xmin)*0.1 x_lim_max = xmax + (xmax-xmin)*0.1 y_lim_min = ymin - (ymax-ymin)*0.1 y_lim_max = ymax + (ymax-ymin)*0.1 return np.array([x_lim_min,x_lim_max,y_lim_min,y_lim_max]) grf_list = {'IGT':0 ,'X50':1, 'X10-X90':2, 'X10-X50':3, 'X50-X90':4, 'Qwork':5, 'Qexhaust':6, 'Qunburn':7, 'Qcool':8} grf_use = [2,3,4,5] for file_index, filepath in enumerate(filepathes): df = pd.read_csv(filepath,header=None) dataheader = np.array(df.iloc[0,:]) datalist = np.array(df.iloc[1:,:],dtype= float).T for grf_index in grf_use: plt.rcParams["font.size"] = 20 plt.rcParams['font.family'] = 'Times New Roman' fig = plt.figure(facecolor = (0,0,0,0)) ax = fig.add_subplot(111) ax.set_facecolor((0,0,0,0)) x_data = datalist[1] y_data = datalist[grf_index] grf_scp = grf_scope(x_data,y_data) plt.xlim(grf_scp[0],grf_scp[1]) plt.ylim(grf_scp[2],grf_scp[3]) plt.xlabel(dataheader[1]) plt.ylabel(dataheader[grf_index]) plt.plot(x_data,y_data) plt.tight_layout() plt.savefig(f"{folderpath}/{dataheader[grf_index]}_graph.png") plt.close()