title: Canvas scroll bar appears but doesn't work
body: <p>I'm writing a program to draw  charts. I emdbed a frame inside a canvas and then draw the charts inside the frame. There's a button embedded to the root. The button is pressed and the charts appear.</p>
  
  <p>Although the  charts  appear, they seem to go out of the window (notice how i want 5 charts but this code produces only 3 on my machine). So I tried various methods of adding a horizontal scroll bar but to no avail. The scroll bar appears but never works.  </p>
  
  <p>Some solutions suggested that I shouldn't pack the frame and instead use canavas.create_window and pass the frame as window. But when I remove the frame.pack() line, the program just crashes. The program works only when i add frame.pack()</p>
  
  <p>Below is my code</p>
  
  <pre><code>from tkinter import *
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  from matplotlib.figure import Figure
  
  def on_configure(event=None):
      canvas.configure(scrollregion=canvas.bbox("all"))
  
  def drawGraph(frame):
  
      for i in range(5):
          f = Figure(figsize=(5,5), dpi=100)
          a = f.add_subplot(111)
          a.plot([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],[5,6,1,3,8,9,3,5,9,7,6,5,7,3,2,9,3,5])
  
          canvas = FigureCanvasTkAgg(f, frame)
          canvas.draw()
          canvas.get_tk_widget().pack(side=LEFT, fill=BOTH, expand=True)
  
  root=Tk()
  canvas=Canvas(root)
  frame=Frame(canvas)
  
  xscrollbar=Scrollbar(canvas, orient=HORIZONTAL)
  xscrollbar.config(command=canvas.xview)
  
  button=Button(root, text='Go',command= lambda: drawGraph(frame))
  button.pack()
  
  canvas.create_window((0,0),window=frame)
  canvas.config(xscrollcommand=xscrollbar.set)
  
  xscrollbar.pack(side=BOTTOM, fill=X)
  canvas.bind("&lt;Configure&gt;", on_configure)
  frame.pack()
  canvas.pack()
  root.mainloop()
  
  </code></pre>
  
  <p>Any help would be appreciated. Thanks.</p>