title: Plotting a line using user tkinter inputs as coordinates with Matplotlib
body: <p>I embed a Matplotlib line chart in my Tkinter GUI environment. My "experiment" basically takes two inputs (numbers) from the user and then it's supposed to use them to draw a line. However, I have no clue on how to plot a line graph based on the user inputs. Can someone please explain how to do it? Here is my code:</p>
  
  <pre><code>from tkinter import *
  import tkinter as tk
  from tkinter import ttk
  import matplotlib.pyplot as plt
  import numpy as np
  
  root = tk.Tk()
  root.geometry('500x700')
  
  first_input = StringVar()
  second_input = StringVar()
  
  class Graph():
      def linechart():
          x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
          y = [1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5]
          plt.plot(x, y)
          plt.xticks(np.arange(min(x), max(x)+1, 1.0))
          plt.show()
  
  class Random(Graph):
      def __init__(self):
          self.label1 = None
          self.label2 = None
          self.userEntry = None
      def first_input(self):
          self.label1 = ttk.Label(text="Insert:")
          self.label1.pack()
          self.userEntry = ttk.Entry(textvariable=first_input)
          self.userEntry.pack()
          self.button_2 = Button(root, text="Enter", command=self.second_input)
          self.button_2.pack()
      def second_input(self):
          self.label2 = ttk.Label(text="Insert:")
          self.label2.pack()
          self.userEntry = ttk.Entry(textvariable=second_input)
          self.userEntry.pack()
          self.button_3 = Button(root, text="Enter", command=self.create_window)
          self.button_3.pack()
      def create_window(self):
          Graph.linechart()
  
  random = Random()
  
  button_1 = Button(root, text="random", command=lambda:random.first_input())
  button_1.pack()
  
  root.mainloop()
  </code></pre>