Created
January 8, 2016 01:45
-
-
Save pjvandehaar/8f5307aacb2dda5f8914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import subprocess, random | |
rows, columns = (int(r) for r in subprocess.check_output([b'stty', b'size']).split()) | |
data1 = [(x*0.1, random.gauss(40,3) - 30*(x/100.)**2) for x in range(0,100)] | |
data2 = [(x*0.1, random.gauss(20,3) + 30*(x/100.)**2) for x in range(0,100)] | |
gnuplot = subprocess.Popen("/usr/bin/gnuplot", stdin=subprocess.PIPE) | |
gnuplot.stdin.write("set term dumb {} {}\n".format(columns - 3, rows - 3).encode()) | |
gnuplot.stdin.write(b"set rmargin 0\n") | |
gnuplot.stdin.write(b"set tmargin 0\n") | |
gnuplot.stdin.write(b"plot '-' title 'foo', '-' title 'bar'\n") | |
for data in (data1, data2): | |
for x,y in data: | |
gnuplot.stdin.write("{} {}\n".format(x,y).encode()) | |
gnuplot.stdin.write(b"e\n") | |
gnuplot.stdin.write(b"exit\n") | |
gnuplot.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment