0

出于某种原因,我一直保存一个空白文件。

import os
from numpy import arange, sin, pi , cos 
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg 
from matplotlib.figure import Figure
from matplotlib import pyplot
import sys 
import pylab



class App: 
    def __init__(self,master, df): 
        frame = Frame(master) 
        frame.grid(row = 0, column = 0) 


        series = df['Daily T'].cumsum()

        self.f = Figure(figsize=(12,6), dpi=100, linewidth=2) 

        chart = self.f.add_subplot(111) 
        chart.grid(True) 
        chart.plot(series, 'r-o')
        chart.set_xticks(range(0,len(series),10)) 

        self.f.autofmt_xdate()

        try: 
            #pyplot.savefig('chart.pdf')
            print 'saved as chart.pdf'
        except Exception, e:
            print str(e)
4

1 回答 1

0

人物有自己的保存方法。所以我会使用:

try:
    self.f.savefig('chart.pdf')
    print 'saved as chart.pdf'
except Exception, e:
    print str(e)
于 2013-11-11T22:22:36.487 回答