I have several .csv files, and i wanted to draw a graph from this files. These files contains two columns , whose the first column is the same for each csv files.
file1.csv:
20 -4.140462670
25 -4.140537060
30 -4.140571620
35 -4.140581580
40 -4.140584350
file2.csv:
20 -4.140468880
25 -4.140542900
30 -4.140577590
35 -4.140587560
40 -4.140590330
I tried with the script below, in order to plot the first:
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
with open('file1.csv') as f:
f=[x.strip() for x in f if x.strip()]
data=[tuple(map(float,x.split())) for x in f[0:]]
oX=[x[0] for x in data]
oY=[x[1] for x in data]
plt.figure(figsize=(9,6))
ax = plt.subplot(111)
ax.yaxis.set_major_formatter(FormatStrFormatter('%.4f'))
ax.plot(oX, oY, color='blue', linestyle='dashdot', linewidth=2, marker='o', markerfacecolor='red', markeredgecolor='black',markeredgewidth=2, markersize=6)
plt.show()
but I want to draw a graph that contains both curves (file1.csv and file2.csv)
In the other time,the problem is solved (with xmgrace software) using the command: xmgrace -free -nxy *
my question is: can I draw a graph that contains multiple curves, after reading multiple files. csv (file1.csv, file2.csv, file3.csv ....).
I note that I have:
1) n amount of CSV (file1.csv, file2.csv, file3.csv ....).
2) same X coordinates
3) different Y coordinates