Hi all,
I'm building a tool that interfaces with a serial port that spits out data. I want to graph the data real time and have chose Gnuplot.py
The number of data 'files' to graph will be flexible but known before execution of the program (up to 6 currently but this could change). I want to write it so that the number a Data objects plotted is flexible without a cascade of if + elif statments as I have already written.
This function is called each time the program grabs another line from the serial data stream and appends values list.
I'm aware that there is probably a way to format the Gnuplot.Data() call to accomdate this but I couldn't figure it out from the documentation.
I'm pretty new to python in general and am doing the best I can. Any thoughts are greatly appreciated.
Thanks!
I'm building a tool that interfaces with a serial port that spits out data. I want to graph the data real time and have chose Gnuplot.py
The number of data 'files' to graph will be flexible but known before execution of the program (up to 6 currently but this could change). I want to write it so that the number a Data objects plotted is flexible without a cascade of if + elif statments as I have already written.
This function is called each time the program grabs another line from the serial data stream and appends values list.
Code:
def rtGraph(g): """ workhouse graphing function """ for file in activefiles: activeindex = activefiles.index(file) #two arrays must be the same for Gnuplot to be happy if len(x) != 0 and len(x) == len(values[activeindex]): d[activeindex] = Gnuplot.Data(x, values[activeindex], title = file) # TODO, fix this crap if len(d) == 1: g.plot(d[0]) elif len(d) == 2: g.plot(d[0],d[1]) elif len(d) == 3: g.plot(d[0],d[1],d[2]) elif len(d) == 4: g.plot(d[0],d[1],d[2],d[3]) elif len(d) == 5: g.plot(d[0],d[1],d[2],d[3],d[4]) elif len9d0 == 6: g.plot(d[0],d[1],d[2],d[3],d[4],d[5]) else: print "Something is wrong with you data: There is none or too much."
I'm pretty new to python in general and am doing the best I can. Any thoughts are greatly appreciated.
Thanks!
Comment