[Ncr-Python.in] HELP REQUIRED [MATPLOTLIB ERROR]

Aniket Maithani maithani.aniket at gmail.com
Thu May 22 14:12:55 CEST 2014


Hello All,

            I am using MATPLOTLIB to plot some data on a realtime basis
using ARDUINO. I have written the following code for my program :
[File Attached a1.txt]

Recently I moved to a new system. I have installed all the dependencies
etc. but now I am getting the following error and I am unable to resolve
it. [f2.png]

Please Help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ncr-python.in/attachments/20140522/6f4f48e8/attachment-0001.html>
-------------- next part --------------
import serial
import numpy as np
from matplotlib import pyplot as plt
ser = serial.Serial('/dev/ttyACM0', 9600)
print ser  
plt.ion() # set plot to animated
 
ydata = [0] * 50
ax1=plt.axes() 
 
# make plot
line, = plt.plot(ydata)
plt.ylim([10,40])
 
# start data collection
while True: 
    data = ser.readline().rstrip() # read data from serial
                                   # port and strip line endings
    if len(data.split(".")) == 2:
        ymin = float(min(ydata))-10
        ymax = float(max(ydata))+10
        plt.ylim([ymin,ymax])
        ydata.append(data)
        del ydata[0]
        line.set_xdata(np.arange(len(ydata)))
        line.set_ydata(ydata)  # update the data
        plt.draw() # update the plot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2.png
Type: image/png
Size: 221146 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ncr-python.in/attachments/20140522/6f4f48e8/attachment-0001.png>


More information about the Ncr-Python.in mailing list