I have trawled through some forums trying to solve this but I am new to programming and I just can't seem to figure it out.
I have two data sets with just 2 columns (x,u)
in data_a*.dat
and (x,v)
in data_b*.dat
. There are 200 files ranging from data_a_001.dat
to data_a_200.dat
and data_b_001.da
t to data_b_200.dat
I am trying to create a set of plots
plot_001.png
to plot_200.png
such that plot_001
has x,u
from data_a_001.da
t as well as v
from data_b_001.dat
and so on till plot_200.png
Thus far I've been using the following code to plot data from single files, but don't know how to get both data files on the same plot.
import numpy as np
import matplotlib
import math
from matplotlib import pyplot as plt
import glob
data = sorted(glob.glob('data_*'))
i=0
for d in data:
if(i<201):
data = np.genfromtxt(fname=d)
x = data[:,0]
v = data[:,1]
plt.plot(x,v,color='blue')
plt.ylim(-1.5,1.5)
k = str(i)
plt.savefig('plot'+k.zfill(4)+'.png')
plt.close()
i = i + 1
matplotlib.pyplot.show()
I don't mind modifying the code or just trying something new to solve the problem.