Python matplotlib.backends.backend_tkagg.NavigationToolbar2Tk() Examples
The following are 4
code examples of matplotlib.backends.backend_tkagg.NavigationToolbar2Tk().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.backends.backend_tkagg
, or try the search function
.
Example #1
Source File: voyagerimb.py From voyagerimb with MIT License | 6 votes |
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)
Example #2
Source File: plot.py From evo with GNU General Public License v3.0 | 5 votes |
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()
Example #3
Source File: plot.py From evo_slam with GNU General Public License v3.0 | 5 votes |
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()
Example #4
Source File: futures_spot_spreads.py From tqsdk-python with Apache License 2.0 | 5 votes |
def draw_toolbar(canvas, root): toolbar = NavigationToolbar2Tk(canvas, root) toolbar.update() canvas._tkcanvas.pack(side='top', fill='both', expand=1) return