0

I am plotting sensor data from FTDI port using plt.plot() from pyplot. Unfortunately I don't see a line for some reason. However when I change mark type: plt.plot(duration, temp, 'o') (or to any other point-like marktype) everything goes as it should. I was trying to increase sleep time (reading problems with plot and live-plotting from other similar questions) but that was not the case.
(I am using Ubuntu 14.04 if that is the case for some reason)

#!/usr/bin/python


import time
import numpy as np
import matplotlib.pyplot as plt

print "We are plotting sonar values"
f = open('/dev/ttyUSB0', 'r')

plt.axis()
plt.ion()
plt.show()
duration = 0;
while True:
    print f.readline()
    temp = f.readline()

    temp = int(temp[1:])
    plt.plot(duration, temp, 'o')
    duration+=1
    plt.draw()
    time.sleep(0.1)

enter image description here enter image description here

arbulgazar
  • 1,931
  • 1
  • 19
  • 24
  • StackOverflow Netiquette encourages Question authors to post also a MCVE -- a Minimum Complete Verifiable Example -- for a problem you ask to get help for. Try to re-edit your post in this direction. – user3666197 Oct 09 '14 at 19:59
  • Check the .show() before plotting + live-plotting from other threads is to be done via a shared Object? – user3666197 Oct 09 '14 at 20:02
  • I mean 'other similar questions', edited this. What you mean by checking the .show()? Tried to plot the first point before the loop, not helped. – arbulgazar Oct 09 '14 at 20:07
  • Maxim, may be this >>> http://stackoverflow.com/a/26268733/3666197 and this >>> http://stackoverflow.com/a/25769600/3666197 may help you for a fast GUI within a real-time control-loop constraints. – user3666197 Oct 09 '14 at 20:23

0 Answers0