I want to print the title of the plot, as the file name it is plotting. so whatever files it plots it should the title as 'Raman Spectra of filename'. I am trying this way but doesn't work
def OnPlot(self, event):
cursor= self.conn.execute("SELECT FILE_NAME FROM MOLECULE where MOL_NUMBER==?", (self.plot_list[0],))
files = cursor.fetchall()
#print files[0][0]
tf = open(files[0][0],'r+')
d = tf.readlines()
tf.seek(0)
for line in d:
s=re.search(r'[a-zA-Z]',line)
if s:
tf.write('#'+line)
else:
tf.write(line)
tf.truncate()
tf.close()
plt.plotfile(str(files[0][0]), delimiter=' ',comments = '#', cols=(0, 1),
names=('Raman Shift ($\mathregular{Cm^{-1}}$)', 'Intensity (arb. units)'), )
plt.title('Raman Spectra of "files"')
plt.show()
The question is a little bit fuzzy:) Something like
plt.title('Raman Spectra of {}'.format(files[0][0]))
?