Reputation: 965
I am creating a popup window using tkinter's Toplevel containing a pyplot graph, and I have been trying to re-size the window so that I can stretch the graph horizontally to get some more x resolution. I haven't had any success in accomplishing this. I have tried to modify the width component of the Toplevel, but it just resized back to the graph size. Below is my code so far. Any suggestions on how to make the code better are always welcome.
import matplotlib
matplotlib.use('TkAgg')
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.backends.backend_tkagg import NavigationToolbar2TkAgg
from matplotlib.figure import Figure
import Tkinter as tk
root = tk.Toplevel(width=2000)
f = Figure()
ax = f.add_subplot(111)
zeroy = [0,25]
zerox = [0, 35]
p3 = ax.plot(zerox, zeroy, 'k-')
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().grid(row=0)
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.grid(row=1, sticky=tk.W)
toolbar.update()
button = tk.Button(root, text='Quit', command = root.destroy)
button.grid(row=2)
root.mainloop()
I am sure that it is something nice and easy, but my googlefu has failed me, and my experiments also failed. Help would be greatly appreciated.
Upvotes: 0
Views: 499
Reputation: 965
The answer to my question was contained in the second row.
f = Figure(figsize=(15,9))
Where the 15 is the horizontal component and the 9 is the vertical.
Edit: I discovered this a few minutes after posting my question, and left the question to aid future people.
Upvotes: 2