Python Forum
Reiszing figure to occupy entire frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reiszing figure to occupy entire frame
#1
I have a frame within my root window and wish to place a plot inside the frame. What I have so far is the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from tkinter import Tk,Frame,TOP,BOTH
from matplotlib import pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import numpy as np
 
plt.rcParams["figure.figsize"] = [18,10]
 
root=Tk()
root.wm_title("Root Window")
root.geometry('1500x1000')
 
x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
fig, ax = plt.subplots()
ax.plot(x, y)
 
canvas_frame=Frame(root,bg='yellow')
canvas_frame.pack(side=TOP,expand=True)
canvas = FigureCanvasTkAgg(fig, master=canvas_frame)
 
canvas.get_tk_widget().pack(side=TOP,fill=BOTH,expand=True)
canvas.draw()
 
root.mainloop()
The problem I have is that I want to increase the plot size so it occupies the entire frame. I'm unsure why adjusting plt.rcParams doesn't do what I need.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Make entire script run again every 45 mo NDillard 0 910 Jan-23-2024, 09:40 PM
Last Post: NDillard
  How to get OpenCV to display entire camera frame? George713 1 4,416 Aug-12-2021, 02:45 AM
Last Post: Pedroski55
  How to apply a class method to an entire dataframe column tirtha9 1 6,093 Jan-03-2021, 04:44 AM
Last Post: klllmmm
  2d Array adds last element to entire list waiteup 2 2,978 Nov-19-2020, 08:25 PM
Last Post: bowlofred
  encrypt entire project mattc 2 3,151 Jul-21-2020, 07:05 AM
Last Post: mattc
  Using OpenPyXL How To Read Entire Column Into Dictionary jo15765 1 3,376 Jun-08-2020, 04:10 AM
Last Post: buran
  How can I paste an entire file from clipboard to a folder? daverave1212 5 11,747 Feb-08-2020, 04:33 PM
Last Post: snippsat
  Subtract 11 from entire list of quoted numbers Pleiades 1 2,293 Nov-14-2019, 10:26 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020