本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.stop_event_loop方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.stop_event_loop方法的具体用法?Python FigureCanvasTkAgg.stop_event_loop怎么用?Python FigureCanvasTkAgg.stop_event_loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.stop_event_loop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import stop_event_loop [as 别名]
#.........这里部分代码省略.........
self.ax1.set_ylim(ymin,ymax)
self.ax1.set_xlim(xmin,xmax)
#Update CT.AX2 by plotting new spline, also perserve the x-axis bounds
self.ax2.plot(self.iwvlngth,self.ispectrum,'k',drawstyle='steps')
self.ax2.plot(xcont,ycont,'b')
self.ax2.plot(self.xspline,self.yspline,'or',picker=5)
self.ax2.set_ylabel('Flux\n(tweaked fit)')
self.ax2.set_ylim(ymin,ymax)
self.ax2.set_xlim(xmin,xmax)
#in CT.AX2, Divide out the spectrum&errorspectrum by the continuum, and plot
self.ax3.plot(xcont,self.ispectrum/ycont,'k',drawstyle='steps')
self.ax3.plot(xcont,1.0-self.espectrum/ycont,'--g',drawstyle='steps')
self.ax3.plot(xcont,1.0+self.espectrum/ycont,'--g',drawstyle='steps')
self.ax3.set_ylabel('Relative flux')
self.ax3.set_xlabel('Wavlength')
self.ax3.set_ylim(-1,2)
self.ax3.plot([self.xmin,self.xmax],[1,1],'--r')
self.ax3.plot([self.xmin,self.xmax],[0,0],'--r')
self.ax3.set_xlim(xmin,xmax)
#Update plotting window
self.TweakPlot.draw()
#Function for closing the current MPL event by it's ID, and stop the event loop
#It might seem redundant that I have both things, but I intend to have a continous
#editing method, which would need the looper.
def QuitEdit(self,cid):
#Close event ID
self.TweakPlot.mpl_disconnect(cid)
#Stop event loop
self.TweakPlot.stop_event_loop()
#Function when "Add Point" button is clicked.
def AddPoint(self):
#Show Tutorial message for what to do.
if usetutorial: tkMessageBox.showinfo("Help Message", "Click where to add point.")
#Start mouse click event, and run CT.ClickAdd
self.cidbut=self.TweakPlot.mpl_connect('button_press_event',self.ClickAdd)
self.TweakPlot.start_event_loop(0)
#If use continuous button is on, repeat adding points
while self.useContinuous.get():
if usetutorial: tkMessageBox.showinfo("Help Message", "Continuous point addition on. Keep adding points.")
try:
self.cidbut=self.TweakPlot.mpl_connect('button_press_event',self.ClickAdd)
self.TweakPlot.start_event_loop(0)
except: self.useContinuous.set(False)
#Given a mouse event for adding a point...
def ClickAdd(self,event):
#Grab the x/y coordiantes of the click, and add to spline
self.xspline.append(event.xdata)
self.yspline.append(event.ydata)
#Sort the spline data to be in order by wavelength
self.xspline,self.yspline=SortList(self.xspline,self.yspline)
#Refresh the plot with new data, but keep y-axis
self.Refresh(yrefresh=False)
#Close the MPL event stuff
self.QuitEdit(self.cidbut)
#Function ro remove a point when "Remove Point" button pressed
def RemovePoint(self):
#Show tutorial message on what to do
if usetutorial: tkMessageBox.showinfo("Help Message", "Click point to remove.")
#Start MPL event for picking an MPL artist, and start the loop. Run CT.ClickRemove
self.cidpick=self.TweakPlot.mpl_connect('pick_event',self.ClickRemove)
self.TweakPlot.start_event_loop(0)