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)