0
다음은 하나의 디렉토리에서 파일을 호출 할 수있는 스크립트입니다. '-o'를 사용하여 명령 줄에서 파일을 선택할 수 있습니다.다른 디렉토리의 여러 파일, 한 그림에 플롯
어떻게 여러 디렉터리에서 여러 파일을 호출하고 같은 그림을 그릴 수 있습니다.
import numpy as np
import matplotlib.pyplot as plt
import csv
import argparse
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(description='This script only works for gromacs rms files and filename should be in 1.xvg, 2.xvg format')
parser.add_argument("-o","--input", help="output as PDF.")
args = parser.parse_args()
input = (args.input)
x, y = [],[]
title = "RMSD"
xlabel = "Time (ns)"
ylabel = "RMSD (nm)"
with open(input) as f:
for line in f:
cols = line.split()
if cols[0][0] == "#":
pass
elif cols[0][0] == "@":
pass
else:
try:
if len(cols) == 2:
x.append(float(cols[0]))
y.append(float(cols[1]))
except ValueError:
pass
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.plot(x,y)
ax1.set_title(title)
ax1.set_xlabel(xlabel)
ax1.set_ylabel(ylabel)
plt.savefig('data.png', dpi=500)