本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg方法的典型用法代码示例。如果您正苦于以下问题:Python backend_tkagg.FigureCanvasTkAgg方法的具体用法?Python backend_tkagg.FigureCanvasTkAgg怎么用?Python backend_tkagg.FigureCanvasTkAgg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg
的用法示例。
在下文中一共展示了backend_tkagg.FigureCanvasTkAgg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [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: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def __init__(self, parent, **kwargs):
tk.Frame.__init__(self, parent, **kwargs)
self.parent = parent
self.degree = 5
self.graphFigure = Figure(figsize=(4,2), dpi=100, facecolor="black")
self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
self.subplot.tick_params(axis="y", colors="grey", direction="in")
self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")
self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
self.graphFigure.subplots_adjust(left=(30/100), bottom=(15/100),
right=1, top=(1-15/100), wspace=0, hspace=0)
self.canvas = FigureCanvasTkAgg(self.graphFigure, self)
self.canvas.get_tk_widget().configure(bg="black")
self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
self.canvas.show()
示例3: makeGraph
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def makeGraph(self):
self.graphFigure = Figure(figsize=(1,0.1), dpi=50, facecolor="black")
self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
self.subplot.tick_params(axis="y", colors="grey", labelbottom="off", bottom="off")
self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")
self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
self.graphFigure.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)
self.graphCanvas = FigureCanvasTkAgg(self.graphFigure, self)
self.graphCanvas.get_tk_widget().configure(bg="black")
self.graphCanvas.get_tk_widget().grid(row="2", column="2", columnspan="3", sticky="news")
yValues = self.mainWindow.characterDetector.playbackLogReader.logEntryFrequency
self.highestValue = 0
for value in yValues:
if value > self.highestValue: self.highestValue = value
self.subplot.plot(yValues, "dodgerblue")
self.timeLine, = self.subplot.plot([0, 0], [0, self.highestValue], "white")
#self.graphFigure.axes[0].set_xlim(0, len(yValues))
self.subplot.margins(0.005,0.01)
self.graphCanvas.show()
self.mainWindow.makeDraggable(self.graphCanvas.get_tk_widget())
示例4: do_plot
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def do_plot(self, osc):
if not matplotlib:
self.statusbar["text"] = "Cannot plot! To plot things, you need to have matplotlib installed!"
return
o = self.create_osc(None, None, osc.input_freq.get(), osc, all_oscillators=self.oscillators).blocks()
blocks = list(itertools.islice(o, self.synth.samplerate//params.norm_osc_blocksize))
# integrating matplotlib in tikinter, see http://matplotlib.org/examples/user_interfaces/embedding_in_tk2.html
fig = Figure(figsize=(8, 2), dpi=100)
axis = fig.add_subplot(111)
axis.plot(sum(blocks, []))
axis.set_title("Waveform")
self.do_close_waveform()
canvas = FigureCanvasTkAgg(fig, master=self.waveform_area)
canvas.get_tk_widget().pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
canvas.draw()
close_waveform = tk.Button(self.waveform_area, text="Close waveform", command=self.do_close_waveform)
close_waveform.pack(side=tk.RIGHT)
示例5: view_init
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [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)
示例6: setup
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [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
示例7: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def __init__(self, env_name, n_channels):
self.n_channels = n_channels
# The seaborn color_palette cubhelix is used to assign visually distinct colors to each channel for the env
self.cmap = sns.color_palette("cubehelix", self.n_channels)
self.cmap.insert(0, (0, 0, 0))
self.cmap = colors.ListedColormap(self.cmap)
bounds = [i for i in range(self.n_channels + 2)]
self.norm = colors.BoundaryNorm(bounds, self.n_channels + 1)
self.root = Tk.Tk()
self.root.title(env_name)
self.root.config(background='white')
self.root.attributes("-topmost", True)
if platform() == 'Darwin': # How Mac OS X is identified by Python
system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
self.root.focus_force()
self.text_message = Tk.StringVar()
self.label = Tk.Label(self.root, textvariable=self.text_message)
self.fig = Figure()
self.ax = self.fig.add_subplot(111)
self.canvas = FigureCanvasTkAgg(self.fig, master=self.root)
self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
self.key_press_handler = self.canvas.mpl_connect('key_press_event', self.on_key_event)
self.key_release_handler = self.canvas.mpl_connect('key_press_event', lambda x: None)
# Set the message for the label on screen
示例8: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def __init__(self, master):
self.master = master
self.master.title('PID tuner Crazyflie')
self.figplot = plt.Figure(figsize=(5, 4), dpi=100)
self.ax2 = self.figplot.add_subplot(111)
self.line2 = FigureCanvasTkAgg(self.figplot, self.master)
self.line2.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
self.scale_Kp = tk.Scale(master, label='scale_Kp', from_=0, to=20,
length=600, tickinterval=2, resolution=0.1,
orient=tk.HORIZONTAL)
self.scale_Ki = tk.Scale(master, label='scale_Ki', from_=0, to=10,
length=600, tickinterval=1, resolution=0.1,
orient=tk.HORIZONTAL)
self.scale_Kd = tk.Scale(master, label='scale_Kd', from_=0, to=10,
length=600, tickinterval=1, resolution=0.1,
orient=tk.HORIZONTAL)
self.scale_Kp.pack()
self.scale_Ki.pack()
self.scale_Kd.pack()
self.pos_array_prev = []
self.sp_array_prev = []
self.time_array_prev = []
示例9: frame2
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def frame2(self):
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
self.frame2 = ttk.Frame(self.master, borderwidth = 2, relief = "groove")
self.frame2.place(bordermode = "outside", relwidth = 0.99, relheight = 0.72, relx = 0, rely = 0.22, x = 5, y = 5, anchor = "nw")
self.frame2.canvas = ttk.Frame(self.frame2, borderwidth = 0)
self.frame2.canvas.place(relwidth = 1, relheight = 1, relx = 0, anchor = "nw")
self.fig = Figure(figsize = (13, 6), facecolor = "white")
self.canvas = FigureCanvasTkAgg(self.fig, master = self.frame2.canvas)
self.fig.canvas.mpl_connect("button_press_event", self._onClick)
self.canvas.get_tk_widget().pack()
示例10: __init__
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def __init__(self, parent, status, title):
ttk.Frame.__init__(self, parent)
self.status = status
self.canvas = FigureCanvasTkAgg(status.figure, self)
self.canvas.show()
self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
self.animation = animation.FuncAnimation(status.figure, lambda i : status.update_plots(i), interval=1000)
示例11: draw_canvas
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [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)
示例12: tabbed_tk_window
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [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()
示例13: draw_figure
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def draw_figure(canvas, figure, loc=(0, 0)):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg
#------------------------------- Beginning of GUI CODE -------------------------------
# define the window layout
示例14: draw_figure
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def draw_figure(canvas, figure, loc=(0, 0)):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg
示例15: draw_figure
# 需要导入模块: from matplotlib.backends import backend_tkagg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
def draw_figure(canvas, figure):
figure_canvas_agg = FigureCanvasTkAgg(figure, canvas)
figure_canvas_agg.draw()
figure_canvas_agg.get_tk_widget().pack(side='top', fill='both', expand=1)
return figure_canvas_agg