title: How to take the derivative of a Signal in Python?
body: <p>I am new at Python language and coding.</p>
  
  <p>I am trying to acquire and differentiate a live signal from a Arduino UNO Board using the USB Serial. So far, I am acquiring the data with no problems, but I cant get information about how to differentiate it.</p>
  
  <p>Would you guys help me on that or point me out where I can get some information on this stuff.</p>
  
  <p>I would really appreciate your help.</p>
  
  <p>Here is my code</p>
  
  <p>Obs.: I am begginer :D</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  from collections import deque
  import serial
  import pyqtgraph as pg
  from pyqtgraph.Qt import QtCore, QtGui
  import numpy as np
  arduinoData = serial.Serial('COM4', 4800)
  
  win = pg.GraphicsWindow()
  win.setWindowTitle('pyqtgraph example: Scrolling Plots')
  
  #    In these examples, the array size is fixed.
  p1 = win.addPlot()
  p2 = win.addPlot()
  
  data1= [0,0]
  vector=deque()
  
  for i in range(300):
  
      string = arduinoData.readline()
      stringx = string.split(',')
  
      time=float(stringx[0])
      distance=float(stringx[1])
      vector=(time, distance) 
      vectorx = np.array(vector)
      data1=np.vstack((data1,vectorx))   
  
  curve1 = p1.plot(data1)
  curve2 = p2.plot(data1)
  ptr1 = 0
  
  
  
  def update1():
      global data1, curve1, ptr1
  
      data1[:-1] = data1[1:]  
  
      string = arduinoData.readline()
  
      stringx = string.split(',')
      time=float(stringx[0])
      distance=float(stringx[1])
      vector=(time, distance)
      vectorx=np.array(vector)
      data1[-1]=vectorx
      #print(data1)
  
      curve1.setData(data1)
  
      ptr1 += 1
      curve2.setData(data1)
      curve2.setPos(ptr1, 0)
  
  # update all plots
  def update():
      update1()
  
  timer = pg.QtCore.QTimer()
  timer.timeout.connect(update)
  timer.start(50)
  
  
  
  ## Start Qt event loop unless running in interactive mode or using pyside.
  if __name__ == '__main__':
      import sys
      if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
          QtGui.QApplication.instance().exec_()
  </code></pre>