title: Using FigureCanvasTkAgg in two TKinter "pages"
body: <p>I am trying to get two TKinter 'pages' each one with a different plot updated using the matplotlib animation function.</p>
  
  <p>The problem is only one of the pages show correctly the plot.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>import matplotlib
  matplotlib.use("TkAgg")
  
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  from matplotlib.figure import Figure
  import matplotlib.animation as animation
  
  import Tkinter as tk
  import ttk
  
  a = Figure(figsize=(4,4))
  plot_a = a.add_subplot(111)
  
  b = Figure(figsize=(4,4))
  plot_b = b.add_subplot(111)
  
  x = [1,2,3,4,5]
  y_a = [1,4,9,16,25]
  y_b = [25,16,9,4,1]
  
  
  def updateGraphs(i):
  
      plot_a.clear()
      plot_a.plot(x,y_a)
  
      plot_b.clear()
      plot_b.plot(x,y_b)
  
  class TransientAnalysis(tk.Tk):
  
      def __init__(self,*args,**kwargs):
  
          tk.Tk.__init__(self,*args,**kwargs)
          tk.Tk.wm_title(self, "Transient Analysis GUI: v1.0")
  
          container = tk.Frame(self)      
          container.pack(side="top", fill="both", expand=True)      
          container.grid_rowconfigure(0, weight=1)
          container.grid_columnconfigure(0, weight=1)
  
          self.frames = {}
  
          for F in ( GraphPageA, GraphPageB):
  
              frame = F(container, self)
  
              self.frames[F] = frame
  
              frame.grid(row=0, column=0, sticky="nsew")
  
          self.show_frame(GraphPageA)
  
      def show_frame(self, cont):
  
          frame = self.frames[cont]
          frame.tkraise()    
  
  class GraphPageA(tk.Frame):
  
      def __init__(self, parent, controller):
  
          tk.Frame.__init__(self, parent)
  
          button1 = ttk.Button(self, text="Show Graph B",
                              command = lambda: controller.show_frame(GraphPageB))
          button1.grid(row=1, column=0,pady=20,padx=10, sticky='w')
  
          canvasA = FigureCanvasTkAgg(a, self)
          canvasA.show()
          canvasA.get_tk_widget().grid(row=1, column=1, pady=20,padx=10, sticky='nsew')
  
  class GraphPageB(tk.Frame):
  
      def __init__(self, parent, controller):
  
          tk.Frame.__init__(self, parent)
  
          button1 = ttk.Button(self, text="Show Graph A",
                              command = lambda: controller.show_frame(GraphPageA))
          button1.grid(row=1, column=0,pady=20,padx=10, sticky='w')
  
          canvasB = FigureCanvasTkAgg(b, self)
          canvasB.show()
          canvasB.get_tk_widget().grid(row=1, column=1, pady=20,padx=10, sticky='nsew')
  
  app = TransientAnalysis()
  app.geometry("800x600")
  aniA    = animation.FuncAnimation(a, updateGraphs, interval=1000)
  aniB    = animation.FuncAnimation(b, updateGraphs, interval=1000)
  app.mainloop()
  </code></pre>
  
  <p>To be more specific, the page that show correctly  the plot is the last on called in the for loop <code>for F in ( GraphPageA, GraphPageB):</code></p>
  
  <p>I also tried using different updateGraphs function, one to each plot, but the result is the same.</p>
  
  <p>How can I have two TKinter pages plotting these two different graphs?
  I am using Python 2.7.</p>