title: Plotting an interactive time-tracker in Pyqtgraph
body: <p>I am currently working to create an interactive time-tracking line which passes through the curve along X-axis.</p>
  
  <p><strong>Problem:</strong> I have been able to code that using Animation from Matplotlib, but have been only able to make the line move (i.e., <em>it is not interactive</em>).</p>
  
  <pre><code>import numpy as np
  import csv
  import csv_splitter
  import matplotlib
  import matplotlib.pyplot as plt
  from matplotlib import animation
  import matplotlib.colors as cm
  from scipy import interpolate
  from scipy import ndimage
  from PIL import Image
  import cv2
  import os
  plt.rcParams['animation.ffmpeg_path'] = unicode ('C:/FFMPEG/bin/ffmpeg.exe')
  
  with open('C:/Users/j/Desktop/Force.csv','r') as input, open('C:/Users/j/Desktop/Op.csv', 'w') as output:
      try:
          read = csv.reader(input)
          for r in read:
              non_blank = (line for line in input if line.strip())            
              for i in range(17):
                  next(read)                
              output.writelines(non_blank)
      finally:
          print("Done!")
  
  data_orig = np.genfromtxt('C:/Users/jkspu/Desktop/Op.csv', dtype =int, delimiter = ",")
  fig = plt.figure()
  X = data_orig[412:524,1]
  Y1 = data_orig[412:524,4]
  Y2 = data_orig[412:524,3]
  Y3 = data_orig[412:524,2]
  
  plt.plot(X, Y1, 'r--', X, Y2, 'b--', X, Y3, 'g--')
  plt.xlabel('Time -----&gt; (ms)')
  plt.ylabel('Force Data -----&gt; (N)')
  
  X_MIN = 2055
  X_MAX = 2615
  Y_MIN = -300
  Y_MAX = 1500
  X_VALS = range(X_MIN, X_MAX+1);
  
  
  def update_line(num, line):
      i = X_VALS[num]
      line.set_data( [i, i], [Y_MIN, Y_MAX])
      return line,
  
  l , v = plt.plot(2055, -200, 2615, 1200, linewidth=2, color= 'gold')
  anim = animation.FuncAnimation(fig, update_line, len(X_VALS), fargs=(l, ), interval=15, blit=True, repeat=False)
  print(update_line)
  
  FFwriter = animation.FFMpegWriter(fps=30, extra_args=['-vcodec', 'libx264'])
  anim.save('basic_animation.mp4', writer = FFwriter)
  plt.show()
  </code></pre>
  
  <p><strong>Goal:</strong> I would be interested to make the time-tracking line interactive as well as it to move (remain animated). For this purpose, I am trying to use Pyqtgraph (hoping to find an interactive solution).</p>
  
  <p>The code I have used is this (but I don't know how to plug in the matplotlib animation in this code):</p>
  
  <pre><code>import numpy as np
  import csv
  import csv_splitter
  import cv2
  import os
  
  from pyqtgraph.Qt import QtGui, QtCore
  import numpy as np
  import pyqtgraph as pg
  
  app = QtGui.QApplication([])
  
  with open('C:/Users/j/Desktop/Force.csv','r') as input, open('C:/Users/j/Desktop/Op.csv', 'w') as output:
      try:
          read = csv.reader(input)
          for r in read:
              non_blank = (line for line in input if line.strip())            
              for i in range(17):
                  next(read)                
              output.writelines(non_blank)
      finally:
          print("Done!")
  
  data_orig = np.genfromtxt('C:/Users/j/Desktop/Op.csv', dtype =int, delimiter = ",")
  
  win = pg.GraphicsWindow(title="Plot")
  win.resize(1000, 600)
  win.setWindowTitle('First_Plot')
  p1 = win.addPlot(title="Parametric, grid enabled")
  X = data_orig[412:524,1]
  Y1 = data_orig[412:524,4]
  Y2 = data_orig[412:524,3]
  Y3 = data_orig[412:524,2]
  
  p1.plot(X, Y1, pen = 'r')
  p1.plot(X, Y2, pen = 'b')
  fig = p1.plot(X, Y3, pen = 'g')
  
  p1.setLabel('left', "Y Axis", units = 'N')
  p1.setLabel('bottom', "X Axis", units = 'ms')
  
  
  
  
  
  
  if __name__ == '__main__':
      import sys
      if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
          QtGui.QApplication.instance().exec_()
  </code></pre>
  
  <p>A picture of how I would ideally be looking forward to:</p>
  
  <p><img src="https://i.stack.imgur.com/CrZ94.jpg" alt="Image"></p>
  
  <p><strong>Request:</strong> May I kindly ask some expertise in having an animated line (+ interactive as well) in Pyqtgraph?</p>
  
  <p>I hope I could be clear, if not please kindly let me know, thanks!</p>