Python 2.7 绘图标题与matplotlib中的文件名相同
我想打印打印打印的标题,作为打印的文件名。因此,无论它绘制的是什么文件,它的标题都应该是“文件名的拉曼光谱”。 我试着这样做,但不起作用Python 2.7 绘图标题与matplotlib中的文件名相同,python-2.7,matplotlib,plot,titlebar,Python 2.7,Matplotlib,Plot,Titlebar,我想打印打印打印的标题,作为打印的文件名。因此,无论它绘制的是什么文件,它的标题都应该是“文件名的拉曼光谱”。 我试着这样做,但不起作用 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[
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()
这个问题有点模糊:)类似于
plt.title('Raman Spectra of {}'.format(files[0][0]))
?