【发布时间】:2014-09-26 09:27:03
【问题描述】:
我正在开发 Tkinter GUI,我想知道是否可以将 Subplot 放入 Tkinter GUI。任何帮助将不胜感激,因为我目前不知道。
import pandas.io.data as web
import matplotlib.pyplot as plt
import datetime
start = datetime.datetime(2010, 1, 1)
end = datetime.datetime(2014, 8, 3)
google = web.DataReader("GOOG", 'yahoo', start, end )
ax1 = plt.subplot2grid((4,4), (0,0), colspan=4)
ax2 = plt.subplot2grid((4,4), (1,0), colspan=2)
top = plt.subplot2grid((4,4), (0, 0), rowspan=3, colspan=4)
top.plot(google.index, google["Close"])
plt.title('Google Stock Price from 2007 - 2012')
bottom = plt.subplot2grid((4,4), (3,0), rowspan=1, colspan=4)
bottom.bar(google.index, google['Volume'])
plt.title('Google Trading Volume in Millions')
plt.gcf().set_size_inches(15,8)
plt.show()
我正在处理这方面的问题,但如果它不是一个完全独立的窗口,我无法将它放入 GUI。
self.root2= Tk()
self.root2.geometry("600x400")
self.root2.title("Stock Visualization")
frame = Frame(self.root2)
frame.grid(row=2,column=0, sticky="s")
frame2 = Frame(self.root2)
frame2.grid(row=0,column=0, sticky = "n")
## self.canvas=Canvas(self.root2, width=300, height=300, background='white')
## self.canvas.grid(row=1,column=0, columnspan = 4)
这是框架的一部分,没有所有的标签等。我已经将 Canvas 注释掉了我希望 Subplot 去哪里。
【问题讨论】:
-
你见过matplotlib.org/examples/user_interfaces/embedding_in_tk.html 我要指出的是,如果你使用 TkAgg 后端,你是在 tk 中使用嵌入
-
我明白了。所以它把它称为画布。你知道我如何将它整合到 Pandas 数据阅读器等中吗?
标签: user-interface matplotlib tkinter python-3.4