title: Plotting incoming TCP data in real-time (filtering out strings?)
body: <p>I'm trying to plot pairs of data values coming in from an instrument over TCP.
  I can successfully receive these values and print them to my UI, but I can't seem to figure out how to plot these values dynamically as they are being received. I've played around with a couple graphing libraries and animate, but the main problem seems to be filtering out the string labels and unwanted characters so I can only plot the float values being received. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      #s.settimeout(10)
      s.connect((TCP_IP, TCP_PORT))
      s.sendall(MESSAGE)
      #s.shutdown(socket.SHUT_WR)
  
      s.setblocking(0) # set port to nonblocking
  
      begin=time.time()     
  
  
      while(1):
        if loop == 15:
          text1.insert(END, "Stopped Recieving Continious Data... Press SEND to continue recieving data \n")
          text1.insert(END, " To Stop Continious Transimisson, SEND *** 0")
          text1.see("end")
          break;
      if logData and time.time()-begin &gt; timeout:
          #print("in if 1")
          break
      elif time.time()-begin &gt; timeout*2:
          #print("in if 2")
          break
      try:    
          logData = s.recv(BUFFER_SIZE).strip('\t\r\n')
          f.write(logData)
          f.write('\n')
          if logData:
              udpData(logData) #prints to UI
              print(repr(logData))
              begin=time.time()
              loop = loop + 1
          else:
              time.sleep(0.1)
      except:
          pass
  
      # perform filtering of strings here or within while loop try?
      # x = logData
  
      #plt.plot(x, color = 'red', marker = 'o', linestyle = 'dashed', linewidth = 2)
      #plt.show()
  </code></pre>
  
  <p>This function is activated by a send message button press within my UI and receives the data successfully and prints and writes to a file. How would I interpret the data and plot when I send a command that gives me a pair of values like this:</p>
  
  <pre><code>    CCT 1
      Conc1: 1004.5    Conc2: 3003.2
      Conc1: 567.4     Conc2: 4034.2
      ...              ...
  </code></pre>
  
  <p>Also it seems like there is a \t char after Conc1:, the values, and Conc2:</p>
  
  <p>Thanks for any input or help :)</p>
  
  <p>Plotting function using text file data has been written too, but strings are in that file as above and my animate function will not parse them correctly, but the main problems is doing this as I relieve data and not from the text file I write to. :</p>
  
  <pre><code>    def animate(i):
         xs = []
         ys = []
        with open("C:\\Users\\aeros\\Desktop\\output6.txt") as graph_data:
            for line in graph_data:
                  x, y = line.split(" ")
                  xs.append(x)
                  ys.append(y)
  
   ax1.clear()
   ax1.plot(xs, ys)
  </code></pre>