When I add the matplotlib canvas to the frame, my output window is just some zoomed in part of the figure, completely ignoring the dimensions I have set up before.
Here is the class I used to set up the GUI. It has no interaction with the rest of my code besides the calling of the class.
class GUI:
def __init__(self, root):
self.root = root
self.root.title('Data Plotter')
self.root.geometry('800x900')
self.create_grid()
self.create_widgets()
def create_grid(self):
for i in range(6):
self.root.rowconfigure(i, weight=1)
for i in range(5):
self.root.columnconfigure(i, weight=1)
def create_widgets(self):
frame = tk.Frame(root, bg='white')
frame.grid(row=1, column=1, rowspan=3, columnspan=3, sticky='nsew')
dropdown= tk.OptionMenu(root, tk.StringVar(), 'Option 1', 'Option 2', 'Option 3', command=self.update_plot)
dropdown.grid(row=0, column=2)
self.fig, self.ax = plt.subplots()
self.canvas = FigureCanvasTkAgg(self.fig, master=frame)
self.canvas.get_tk_widget().pack()
def update_plot(self):
pass
I started creating this GUI for a personal project. The matplot figure is supposed to fill in the frame I have set up so I have space around for some buttons and stuff. Thank you in advance for helping me out.