title: Matplotlib Lines is plotting extra lines in my plot
body: <p>I'm trying to visualize a pair of two lists, represented by <code>lines_x</code> and <code>lines_y</code> which are meant to be plugged into the coordinates argument of either the <code>plot</code> function in Axes or in Lines2D.</p>
  
  <p>Right now, I'm getting this result, which has extra lines compared to the result I am trying to get.
  What I'm currently getting:</p>
  
  <p><a href="https://i.stack.imgur.com/MOi1L.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MOi1L.png" alt="enter image description here"></a></p>
  
  <p>Previously, I tried using a loop to plot the lines one by one, and that worked for a while. However, after a few runs, it no longer worked.</p>
  
  <p>Could someone please suggest a way for me to achieve the following result on my window?</p>
  
  <p>The plot I want to achieve:</p>
  
  <p><a href="https://i.stack.imgur.com/Vy4Ue.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vy4Ue.jpg" alt="enter image description here"></a></p>
  
  <pre><code>from pylab import *
  import matplotlib
  from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
  from matplotlib.figure import Figure
  import  matplotlib.pylab as plt
  import matplotlib.pyplot as pltplot
  import matplotlib.lines
  from matplotlib.collections import LineCollection
  matplotlib.use ("gTkAgg")
  
  import numpy as np
  
  import tkinter as tk
  from tkinter import Tk
  from tkinter import *
  
  class Window (Frame):
      lines_x = [-2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 0, 1, 1, 2, -2, 2, -2, -1, -1, 0]
      lines_y = [0, 1, 1, 2, -2, 2, -2, -1, -1, 0, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2]
  
      def __init__(self, parent = None):
  
          Frame.__init__(self,parent)
          parent.title("Shape Grammar Interpreter")
  
          self.top=Frame()
          self.top.grid()
          self.top.update_idletasks
  
          self.menu()
          self.makeWidgets()
  
      def makeWidgets(self):
          self.f = Figure(figsize = (6,6), dpi = 100)
          self.a = self.f.add_subplot(111)
  
          #self.a.plot(self.lines_x, self.lines_y, linewidth = 4.0,  picker=5)
  
          line = Line2D(self.lines_x, self.lines_y)
  
          self.a.add_line(line)
          for i in range(len(self.lines_x)):
              self.a.plot(self.lines_x[i:i+1], self.lines_y[i:i+1], linewidth = 4.0)
  
          #self.a.plot(lines_x, lines_y, linewidth = 4.0, color = "blue")
          self.a.margins(y=0.5)
          self.a.margins(x=0.5)
          #self.a.axes.get_xaxis().set_visible(False)
          #self.a.axes.get_yaxis().set_visible(False) 
  
          # a tk.DrawingArea
          self.canvas = FigureCanvasTkAgg(self.f, master=self.top)
  
          #to show window
          self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
  
      def menu(self):
          menubar = Menu (root)
  
          #to close window
          menubar.add_command(label="Exit", command=self.quit_window)
          root.config(menu=menubar)
  
      def quit_window(self):
          root.quit()
          root.destroy()
  
  
  if __name__ == "__main__":
  
      root = Tk()
      my_gui = Window(root)
      root.mainloop()
  </code></pre>