title: Control imbedded figure size on Tkinter canvas?
body: <p>I dont seem to be able to fully control the figure size on my embedded figure on a Tkinter canvas.</p>
  
  <p>Heres what i want to do. Maybe you have another suggestion, than using the embedded figure.</p>
  
  <p>Im trying to make a simple script to make some visual content. Right now its just a pixel mapping of falling squares in random colors.</p>
  
  <p>My problem is that i need it to be fullscreen, and i can for my life not figure out how.</p>
  
  <p>It is mainly about this piece of code, i think:</p>
  
  <pre><code>fig = plt.figure(figsize=(40,40))
  im = plt.imshow(top.img) # later use a.set_data(new_data)
  plt.tick_params(
      axis='both',          # changes apply to the x-axis
      which='both',      # both major and minor ticks are affected
      bottom='off',      # ticks along the bottom edge are off
      top='off',         # ticks along the top edge are off
      left='off',
      right='off',
      labelleft='off',
      labelbottom='off') # labels along the bottom edge are off
  
  
  # a tk.DrawingArea
  canvas = FigureCanvasTkAgg(fig, master=top)
  canvas.show()
  canvas.get_tk_widget().pack(side=gui.TOP , fill=gui.BOTH, expand=1)
  </code></pre>
  
  <p>It seems that figsize has a limit to how big it goes.</p>
  
  <p>Heres all the code:</p>
  
  <pre><code>import matplotlib
  import numpy as np
  matplotlib.use('TkAgg')
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  from matplotlib import figure
  import matplotlib.pyplot as plt
  import tkinter as gui
  from math import floor
  import time
  
  class FullScreenApp(object):
      def __init__(self, master, **kwargs):
          self.master=master
          pad=3
          self._geom='200x200+0+0'
          master.geometry("{0}x{1}+0+0".format(
              master.winfo_screenwidth()-pad, master.winfo_screenheight()-pad))
          master.bind('&lt;Escape&gt;',self.toggle_geom)            
      def toggle_geom(self,event):
          geom=self.master.winfo_geometry()
          print(geom,self._geom)
          self.master.geometry(self._geom)
          self._geom=geom
  
  def flashBox(color,oy,ox):
      global j1, j2
      top.img[0+oy:j2+oy,0+ox:j1+ox] = color
      im.set_data(top.img)
      canvas.draw();
      time.sleep(t)
      top.img[0+oy:j2+oy,0+ox:j1+ox] = [0,0,0]
      im.set_data(top.img)
      canvas.draw();
      return top.img
  
  def drawBox(color,oy,ox):
      global j1, j2
      top.img[0+oy:j2+oy,0+ox:j1+ox] = color
      im.set_data(top.img)
      canvas.draw();
      time.sleep(t)
      return top.img
  
  def resetBox(oy,ox):
      global j1, j2
      top.img[0+oy:j2+oy,0+ox:j1+ox] = [0,0,0]
      im.set_data(top.img)
      canvas.draw();
      return top.img
  
  def drawColumn(color,u):
      global gridsize, j1, j2
      for l in range(gridsize):
          im.set_data(flashBox(color,j2*l,j1*u))
          time.sleep(t2)
  
  top = gui.Tk()
  t = 0.1
  t2 = 0.00001
  x = 40
  y = 40
  gridsize = 10
  j1 = floor(x // gridsize)
  j2 = floor(y // gridsize)
  
  top.img = np.zeros([y,x,3],dtype=np.uint8)
  top.img.fill(0) # or img[:] = 255
  
  
  fig = plt.figure(figsize=(40,40))
  im = plt.imshow(top.img) # later use a.set_data(new_data)
  plt.tick_params(
      axis='both',          # changes apply to the x-axis
      which='both',      # both major and minor ticks are affected
      bottom='off',      # ticks along the bottom edge are off
      top='off',         # ticks along the top edge are off
      left='off',
      right='off',
      labelleft='off',
      labelbottom='off') # labels along the bottom edge are off
  
  
  # a tk.DrawingArea
  canvas = FigureCanvasTkAgg(fig, master=top)
  canvas.show()
  canvas.get_tk_widget().pack(side=gui.TOP , fill=gui.BOTH, expand=1)
  
  #app=FullScreenApp(top)
  
  while True:
      for n in range(gridsize):
          top.update()
          p = np.random.randint(0,99)        
          #drawColumn([np.random.random_integers(0,255),np.random.random_integers(0,255),np.random.random_integers(0,255)],np.random.random_integers(0,gridsize-1))
          if p &gt; 10:
              flashBox([np.random.random_integers(0,255),np.random.random_integers(0,255),np.random.random_integers(0,255)],j1*np.random.random_integers(0,gridsize-1),j2*np.random.random_integers(0,gridsize-1))
          else:
              flashBox([0,0,0],0,0)
  </code></pre>