Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 绘图标题与matplotlib中的文件名相同_Python 2.7_Matplotlib_Plot_Titlebar - Fatal编程技术网

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]))
?