本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.copy_from_bbox方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.copy_from_bbox方法的具体用法?Python FigureCanvasTkAgg.copy_from_bbox怎么用?Python FigureCanvasTkAgg.copy_from_bbox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.copy_from_bbox方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Plotting
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import copy_from_bbox [as 别名]
def Plotting(queue):
while queue.get() != "Start Plotting Process":
wait = "Waiting"
timeNow = datetime.time(datetime.now())
time = timeNow.minute + (timeNow.second + timeNow.microsecond/1000000.0)/60.0
lastX = time
lastY = 90250
connect = True
step = 0
x=[]
y=[]
mode = "24-Hour-Plot"
root = tk.Tk()
root.wm_title("PyAmaseis v1.0")
root.iconbitmap(r'icons/icon.ico')
root.wm_state('zoomed')
graphHeightConst = 2500
fig = plt.figure(figsize=(15,10))
fig.set_tight_layout(0.4)
ax = fig.add_subplot(1,1,1)
ax.set_xlim(0,60)
ax.set_ylim(30250,92750)
ax.set_xlabel('Time(minutes)')
xAxis = [0,60]
yAxis = [30250,92750]
y1 = (np.arange(min(yAxis), max(yAxis)+1,graphHeightConst))
y2 = calculateYAxisLabels()
ax.set_xticks(np.arange(min(xAxis), max(xAxis)+1,1))
plt.yticks(y1, y2)
ax.yaxis.grid(color = '#0000FF' )
ax.set_axisbelow(True)
line, = ax.plot(x, y, color='k')
canvas = FigureCanvasTkAgg(fig, master=root)
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
label = tk.Label(text="")
label.pack()
background = canvas.copy_from_bbox(ax.bbox)
canvas.draw()
root.after(0, plotData,queue, fig, ax, canvas, label, root, lastY, lastX, connect, background, line, mode)
root.mainloop()
示例2: StripChartWdg
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import copy_from_bbox [as 别名]
#.........这里部分代码省略.........
if subplot.get_autoscaley_on():
subplot.relim()
subplot.autoscale_view(scalex=False, scaley=True)
self.canvas.draw()
def setDoAutoscale(self, doAutoscale, subplotInd=0):
"""Turn autoscaling on or off for the specified subplot
You can also turn off autoscaling by calling setYLimits.
"""
doAutoscale = bool(doAutoscale)
subplot = self.subplotArr[subplotInd]
subplot.set_ylim(auto=doAutoscale)
if doAutoscale:
subplot.relim()
subplot.autoscale_view(scalex=False, scaley=True)
def setYLimits(self, minY, maxY, subplotInd=0):
"""Set y limits for the specified subplot and disable autoscaling.
Note: if you want to autoscale with a minimum range, use showY.
"""
self.subplotArr[subplotInd].set_ylim(minY, maxY, auto=False)
def showY(self, y0, y1=None, subplotInd=0):
"""Specify one or two values to always show in the y range.
Inputs:
- subplotInd: index of subplot
- y0: first y value to show
- y1: second y value to show; None to omit
Warning: setYLimits overrides this method (but the values are remembered in case you turn
autoscaling back on).
"""
subplot = self.subplotArr[subplotInd]
yMin, yMax = subplot.get_ylim()
if y1 is not None:
yList = [y0, y1]
else:
yList = [y0]
doRescale = False
for y in yList:
subplot.axhline(y, linestyle=" ")
if subplot.get_autoscaley_on() and numpy.isfinite(y) and not (yMin <= y <= yMax):
doRescale = True
if doRescale:
subplot.relim()
subplot.autoscale_view(scalex=False, scaley=True)
def _handleDrawEvent(self, event=None):
"""Handle draw event
"""
# print "handleDrawEvent"
for subplot in self.subplotArr:
subplot._scwBackground = self.canvas.copy_from_bbox(subplot.bbox)
for line in subplot._scwLines:
subplot.draw_artist(line.line2d)
self.canvas.blit(subplot.bbox)
def _handleMap(self, evt):
"""Handle map event (widget made visible)
"""
self._isVisible = True
self._handleDrawEvent()
self._updateTimeAxis()
def _handleUnmap(self, evt):
"""Handle unmap event (widget made not visible)
"""
self._isVisible = False
def _updateTimeAxis(self):
"""Update the time axis; calls itself
"""
tMax = time.time() + self.updateInterval
tMin = tMax - self._timeRange
minMplDays = self._cnvTimeFunc(tMin)
maxMplDays = self._cnvTimeFunc(tMax)
self._purgeCounter = (self._purgeCounter + 1) % self._maxPurgeCounter
doPurge = self._purgeCounter == 0
if doPurge:
for subplot in self.subplotArr:
for line in subplot._scwLines:
line._purgeOldData(minMplDays)
if self._isVisible or self._isFirst:
for subplot in self.subplotArr:
subplot.set_xlim(minMplDays, maxMplDays)
if doPurge:
if subplot.get_autoscaley_on():
# since data is being purged the y limits may have changed
subplot.relim()
subplot.autoscale_view(scalex=False, scaley=True)
self._isFirst = False
self.canvas.draw()
self._timeAxisTimer.start(self.updateInterval, self._updateTimeAxis)
示例3: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import copy_from_bbox [as 别名]
#.........这里部分代码省略.........
self.var_func.set(self.function_list[0])
self.MotorMenu = OptionMenu(self.buttonframe,self.var_func, *self.function_list, command = self.init_function)
self.MotorMenu.grid(row = 3,column =1,sticky = W)
self.normalization_constant = 1
self.scale_list = []
self.var_list = []
self.fig = Figure(figsize=(5,3))
self.ax1 = self.fig.add_subplot(111)
dataplot = self.ax1.plot(arange(2800,3605,5),zeros((161,)),animated = True)[0]#(ax = self.ax1).lines[-1]
guessplot = self.ax1.plot(arange(2800,3605,5),zeros((161,)),animated = True)[0]
self.canvas = FigureCanvasTkAgg(self.fig,master = self.plotframe)
self.canvas.show()
self.canvas._tkcanvas.pack(side=TOP, fill = BOTH,expand =True)
self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.plotframe)
self.toolbar.update()
self.toolbar.pack(side= BOTTOM, fill = BOTH,expand =True)#,expand = True)#fill=BOTH)#, expand=1)
self.canvas.draw()
self.canvas.show()
self.background = self.canvas.copy_from_bbox(self.ax1.bbox)
self.reference = numpy.ndarray((161,))
self.reference[:] = 1
self.reference_name = ''
self.guess = list()
self.name = ['']
if ramanspectrum is None:
self.a = pandas.Series(zeros(161),arange(2800,3605,5))
else:
self.a = copy(ramanspectrum)
print self.a
self.t.insert(END,'data multiplied by'+str(1/max(self.a)))
self.a[:]/=max(self.a.values)
self.startfreq_text = Entry(self.buttonframe,width = 5)
self.startfreq = min(array(self.a.index))
self.startfreq_text.insert(END,str(self.startfreq))
self.startfreq_text.bind("<Return>", self.update_limits)
self.startfreq_text.grid(row = 0 , column =1,sticky = W)
self.endfreq_text = Entry(self.buttonframe,width = 5)
self.endfreq = max(array(self.a.index))
self.endfreq_text.insert(END,str(self.endfreq))
self.endfreq_text.bind("<Return>", self.update_limits)
self.endfreq_text.grid(row = 1 , column =1,sticky = W)
if self.init_function('OneLorentzian') == -1:
self.t.insert(END, 'error initializing fit function')
示例4: MultichannelPlot
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import copy_from_bbox [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
#.........这里部分代码省略.........