出于某种原因,我一直保存一个空白文件。
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)
答案 0 :(得分:0)
数字有自己的保存方法。所以我会用:
try:
self.f.savefig('chart.pdf')
print 'saved as chart.pdf'
except Exception, e:
print str(e)