I am new in Python (and in programming at all) and trying to build the program for .csv
data analysis.
I have multiple .csv
files and for each of them I build a plot.
How do I add the name of the corresponding file to the title of the plot?
Thanks!
Below is the coresponding part of the code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import glob
for fName in glob.glob('*.csv'):
df, loops = openF(fName)
fig, ax = plt.subplots(1, 1)
for i in range(loops):
df.loc[df['loop']==i+1][['freq','phase']].plot(x='freq', y='phase', logx=True, ax=ax)
ax.set_title('Phase/Freq'.format(fName))
ax.set_xlabel('Frequency, [Hz]')
ax.set_ylabel('Phase, [rad]')
plt.show()