本文整理汇总了Python中matplotlib.backends.backend_tkagg.NavigationToolbar2Tk方法的典型用法代码示例。如果您正苦于以下问题:Python backend_tkagg.NavigationToolbar2Tk方法的具体用法?Python backend_tkagg.NavigationToolbar2Tk怎么用?Python backend_tkagg.NavigationToolbar2Tk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg
的用法示例。
在下文中一共展示了backend_tkagg.NavigationToolbar2Tk方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: view_init
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk [as 别名]
def view_init(self):
self.frame = tk.LabelFrame(self.browser.workframe, text=" Image ")
self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7)
self.figure = plt.figure(figsize=(8, 12), dpi=70)
self.ax1 = plt.subplot2grid((50,40), (0, 0), rowspan=40, colspan=40)
self.ax2 = plt.subplot2grid((50,40), (42, 0), rowspan=8, colspan=40, sharex=self.ax1)
plt.subplots_adjust(left=0.1, bottom=0.05, right=0.95, top=0.97, wspace=0.2, hspace=0.2)
self.view_plot_image()
self.canvas = FigureCanvasTkAgg(self.figure, self.frame)
if self.mpltlib3:
self.canvas.draw()
toolbar = NavigationToolbar2Tk(self.canvas, self.frame).update()
else:
self.canvas.show()
toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame).update()
self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, padx=2, pady=2, expand=True)
self.frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=7, pady=7)
示例2: tabbed_tk_window
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk [as 别名]
def tabbed_tk_window(self):
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
import sys
if sys.version_info[0] < 3:
import Tkinter as tkinter
import ttk
else:
import tkinter
from tkinter import ttk
self.root_window = tkinter.Tk()
self.root_window.title(self.title)
# quit if the window is deleted
self.root_window.protocol("WM_DELETE_WINDOW", self.root_window.quit)
nb = ttk.Notebook(self.root_window)
nb.grid(row=1, column=0, sticky='NESW')
for name, fig in self.figures.items():
fig.tight_layout()
tab = ttk.Frame(nb)
canvas = FigureCanvasTkAgg(self.figures[name], master=tab)
canvas.draw()
canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH,
expand=True)
toolbar = NavigationToolbar2Tk(canvas, tab)
toolbar.update()
canvas._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH,
expand=True)
for axes in fig.get_axes():
if isinstance(axes, Axes3D):
# must explicitly allow mouse dragging for 3D plots
axes.mouse_init()
nb.add(tab, text=name)
nb.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)
self.root_window.mainloop()
self.root_window.destroy()
示例3: draw_toolbar
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2Tk [as 别名]
def draw_toolbar(canvas, root):
toolbar = NavigationToolbar2Tk(canvas, root)
toolbar.update()
canvas._tkcanvas.pack(side='top', fill='both', expand=1)
return