I want to show the plot canvas in the top right side of UI (using Tkinter python3). I wrote the following code but I got the following error:

```
canvas = FigureCanvasTkAgg(fig, master=root) NameError: name 'root' is not defined

```

My code is:

```
import tkinter as tk
import tkinter.ttk as ttk
from tkinter import *
import matplotlib.pyplot as plt
from  matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from matplotlib.figure import Figure
import sys

class GUI(tk.Frame):

   def __init__(self, master = None):
       self.root = tk.Tk()
       self.root.geometry("500x500")
       tk.Frame.__init__(self, master)
       self.createWidgets()

    def start(self):
        self.root.mainloop()

    def createWidgets(self):
        fig = plt.figure(figsize=(8, 8))
        canvas = FigureCanvasTkAgg(fig, master=root)
        canvas.get_tk_widget().grid(row=0, column=1)
        canvas.show()

def main():
    appstart = GUI()
    appstart.start()

if __name__ == "__main__":
    main()

```