本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.restore_region方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.restore_region方法的具体用法?Python FigureCanvasTkAgg.restore_region怎么用?Python FigureCanvasTkAgg.restore_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.restore_region方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import restore_region [as 别名]
#.........这里部分代码省略.........
pass
return 0
def recalc_data(self):
if self.raw.shape == self.reference.shape:
self.a= SG_Smooth(self.raw,width = 11,order = 3)/self.reference/self.normalization_constant
self.ax1.cla()
plot(self.a[0],self.raw/self.reference)
plot(self.a[0],self.a[1])
else:
self.t.insert(END, "reference invalid")
self.reference_name = "No IR Reference"
self.ax1.cla()
self.ax1.plot(self.a[0],self.a[1])
self.canvas.draw()
return 0
def guessdraw(self,ex):
global function,guessplot,dataplot
x = array(self.a.index[self.startidx:self.endidx+1])
for i in range(len(self.guess)):
self.guess[i] = self.scale_list[i].get()
self.canvas.restore_region(self.background)
self.ax1.lines[-1].set_xdata(x)
self.ax1.lines[-1].set_ydata(function(x,*self.guess))
for l in self.ax1.lines:
self.ax1.draw_artist(l)
self.canvas.blit(self.ax1.bbox)
return 0
def fit_and_draw(self):
global function
print type(self.a)
if type(self.a) == pandas.core.series.Series:
self.a = RamanSpectrum(self.a)
#result = fitspectrum(self.a, (float(self.a.index[self.startidx]),float(self.a.index[self.endidx+1])),'Custom',self.guess,function = function)
print self.guess
result = fitspectrum(self.a, (self.startfreq,self.endfreq),'Custom',self.guess,function = function)
fittingparameters = result[0]
xfit = result[1]
yfit = result[2]
if result == -1:
tkMessageBox.showerror('Fit Failed')
return 0
z = list(fittingparameters[0])
示例2: MultichannelPlot
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import restore_region [as 别名]
class MultichannelPlot(matplotlib.figure.Figure):
def __init__(self, master, row=0, column=0, rowspan=5, columnspan=5, width=5, height=3, update_prot="blit"):
matplotlib.figure.Figure.__init__(self, figsize=(width, height))
self.update_prot = update_prot
self.frame = Frame(master=master)
self.frame.config(bd=5)
self.frame.grid(row=row, column=column, padx=5, pady=5)
self.channel_list = []
self.array_list = []
self.color_list = ["r", "b", "g", "c", "m", "y", "k"]
self.a = self.add_subplot(MultichannelAxis(self, 111))
self.canvas = FigureCanvasTkAgg(self, master=self.frame)
self.canvas.show()
self.canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=True)
self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame)
self.toolbar.update()
self.toolbar.pack(side=BOTTOM, fill=BOTH, expand=True) # ,expand = True)#fill=BOTH)#, expand=1)
self.canvas.draw()
self.background = self.canvas.copy_from_bbox(self.a.bbox)
return None
def AddChannel(self, spec_array, channel_type, color=None):
if color == None or color == "":
self.a.add_line(Channel([], [], self, spec_array, channel_type, color=self.color_list[0]))
self.color_list.append(self.color_list[0])
del (self.color_list[0])
else:
self.a.add_line(Channel([], [], self, spec_array, channel_type, color=color))
# self.Update()
self.Redraw()
return self.a.lines[-1]
def RemoveChannel(self, channel):
self.a.lines.remove(channel)
self.Redraw()
return 0
def SetChannelColor(self, channel, clr):
if clr != "":
channel.color = clr
else:
channel.color = self.color_list[0]
self.color_list.append(self.color_list[0])
del (self.color_list[0])
return 0
def ShowChannel(self, channel):
channel.set_visible(True)
self.Update()
return 0
def HideChannel(self, channel):
channel.set_visible(False)
self.Update()
return 0
def Redraw(self):
self.a.relim()
self.a.autoscale_view(tight=False)
self.canvas.draw()
self.canvas.restore_region(self.background)
for line in self.a.lines:
self.a.draw_artist(line)
self.canvas.blit(self.a.bbox)
return 0
def SaveFigure(self, filename):
self.f_copy = self.a
self.f_copy.savefig("a.png")
return 0
def Update(self):
if self.update_prot == "draw":
self.canvas.draw()
return 0
(lower_y_lim, upper_y_lim) = self.a.get_ylim()
(lower_x_lim, upper_x_lim) = self.a.get_xlim()
scaley_bool = False
scalex_bool = False
scaley_down_bool = True
#.........这里部分代码省略.........