本文整理汇总了Python中matplotlib.backends.backend_tkagg.NavigationToolbar2TkAgg方法的典型用法代码示例。如果您正苦于以下问题:Python backend_tkagg.NavigationToolbar2TkAgg方法的具体用法?Python backend_tkagg.NavigationToolbar2TkAgg怎么用?Python backend_tkagg.NavigationToolbar2TkAgg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg
的用法示例。
在下文中一共展示了backend_tkagg.NavigationToolbar2TkAgg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg [as 别名]
def __init__(self, root, controller):
f = Figure()
ax = f.add_subplot(111)
ax.set_xticks([])
ax.set_yticks([])
ax.set_xlim((x_min, x_max))
ax.set_ylim((y_min, y_max))
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
canvas.mpl_connect('key_press_event', self.onkeypress)
canvas.mpl_connect('key_release_event', self.onkeyrelease)
canvas.mpl_connect('button_press_event', self.onclick)
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.update()
self.shift_down = False
self.controllbar = ControllBar(root, controller)
self.f = f
self.ax = ax
self.canvas = canvas
self.controller = controller
self.contours = []
self.c_labels = None
self.plot_kernels()
示例2: view_init
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg [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)
示例3: setup
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg [as 别名]
def setup(self, channels):
print "Setting up the channels..."
self.channels = channels
# Setup oscilloscope window
self.root = Tkinter.Tk()
self.root.wm_title("PiScope")
if len(self.channels) == 1:
# Create x and y axis
xAchse = pylab.arange(0, 4000, 1)
yAchse = pylab.array([0]*4000)
# Create the plot
fig = pylab.figure(1)
self.ax = fig.add_subplot(111)
self.ax.set_title("Oscilloscope")
self.ax.set_xlabel("Time")
self.ax.set_ylabel("Amplitude")
self.ax.axis([0, 4000, 0, 3.5])
elif len(self.channels) == 2:
# Create x and y axis
xAchse = pylab.array([0]*4000)
yAchse = pylab.array([0]*4000)
# Create the plot
fig = pylab.figure(1)
self.ax = fig.add_subplot(111)
self.ax.set_title("X-Y Plotter")
self.ax.set_xlabel("Channel " + str(self.channels[0]))
self.ax.set_ylabel("Channel " + str(self.channels[1]))
self.ax.axis([0, 3.5, 0, 3.5])
self.ax.grid(True)
self.line1 = self.ax.plot(xAchse, yAchse, '-')
# Integrate plot on oscilloscope window
self.drawing = FigureCanvasTkAgg(fig, master=self.root)
self.drawing.show()
self.drawing.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
# Setup navigation tools
tool = NavigationToolbar2TkAgg(self.drawing, self.root)
tool.update()
self.drawing._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
return
示例4: draw_canvas
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg [as 别名]
def draw_canvas(self):
"""Draw canvas figure."""
# Create figure with subplots, a canvas to hold them, and add
# matplotlib navigation toolbar.
if self.layer_to_plot.get() is '':
return
if hasattr(self, 'plot_container') \
and not self.settings['open_new'].get() \
and not self.is_plot_container_destroyed:
self.plot_container.wm_withdraw()
self.plot_container = tk.Toplevel(bg='white')
self.plot_container.geometry('1920x1080')
self.is_plot_container_destroyed = False
self.plot_container.wm_title('Results from simulation run {}'.format(
self.selected_plots_dir.get()))
self.plot_container.protocol('WM_DELETE_WINDOW', self.close_window)
tk.Button(self.plot_container, text='Close Window',
command=self.close_window).pack()
f = plt.figure(figsize=(30, 15))
f.subplots_adjust(left=0.01, bottom=0.05, right=0.99, top=0.99,
wspace=0.01, hspace=0.01)
num_rows = 3
num_cols = 5
gs = gridspec.GridSpec(num_rows, num_cols)
self.a = [plt.subplot(gs[i, 0:-2]) for i in range(3)]
self.a += [plt.subplot(gs[i, -2]) for i in range(3)]
self.a += [plt.subplot(gs[i, -1]) for i in range(3)]
self.canvas = FigureCanvasTkAgg(f, self.plot_container)
graph_widget = self.canvas.get_tk_widget()
graph_widget.pack(side='top', fill='both', expand=True)
self.toolbar = NavigationToolbar2TkAgg(self.canvas, graph_widget)