gstreamer/tests/plot-data

51 lines
1 KiB
Text
Raw Normal View History

#!/usr/bin/env python
from __future__ import division
import pylab
import optparse
import sys
def read_line(fd):
l = fd.readline()
if not l:
return None
l = l.strip()
if l[0] == ';':
return read_line(fd)
return [float(x) for x in filter(None, l.split(' '))]
def read_data(fd):
data = []
l = read_line(fd)
while l:
data.append(l)
l = read_line(fd)
return data
def make_xticks(start, end, numticks):
return range(int(start), int(end), int((start-end)/numticks))
def make_plot(title):
l = sys.stdin.readline()
labels = l.strip().split(';')
data = read_data(sys.stdin)
domain = [x[0] for x in data]
for i in range(1,len(labels)):
pylab.plot(domain, [x[i] for x in data], label=labels[i])
pylab.legend()
pylab.ylabel(r'Clock time (s)')
pylab.xlabel(r'Real time (s)')
pylab.title(title)
pylab.grid(True)
pylab.show()
def main(args):
parser = optparse.OptionParser()
title = ' '.join(args[1:])
make_plot(title)
main(sys.argv)