【问题标题】:Title of plot same as filename in matplotlib绘图标题与 matplotlib 中的文件名相同
【发布时间】:2017-07-25 16:57:39
【问题描述】:

我想打印绘图的标题,作为绘图的文件名。所以无论它绘制什么文件,它的标题都应该是“文件名的拉曼光谱”。 我正在尝试这种方式,但不起作用

   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()

【问题讨论】:

    标签: python-2.7 matplotlib plot titlebar


    【解决方案1】:

    这个问题有点模糊:) 像

    plt.title('Raman Spectra of {}'.format(files[0][0]))
    

    ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-07
      • 2018-08-30
      • 1970-01-01
      • 2014-04-06
      • 2021-02-07
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      相关资源
      最近更新 更多