gstreamer/tests/misc/plot-data
Andy Wingo 3433bdcf17 tests/network-clock.scm (plot-simulation): Pipe data to the elite python skript.
Original commit message from CVS:
2005-06-23  Andy Wingo  <wingo@pobox.com>

* tests/network-clock.scm (plot-simulation): Pipe data to the
elite python skript.

* tests/network-clock-utils.scm (define-parameter): New macro,
defines a parameter that can be set via the command line.
(set-parameter!, parse-parameter-arguments): Command line args
parser.

* tests/plot-data: Simple matplotlib-based plotter, takes input on
stdin.
2005-06-23 13:20:44 +00:00

50 lines
1 KiB
Python
Executable file

#!/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)