Wednesday, February 24, 2021

Python: Easy line plots

Need to just plot a file with numbers? Stop using matl@b or excl.

All we need is a couple lines of Python code:

import matplotlib.pyplot as p


And for the values (if you have the number with new-line separating them) with either a file as an argument of just the stdin couple more lines:

import sys

stream = sys.stdin
if len(sys.argv) > 1:
    stream = open(sys.argv[1], 'r')

values = [float(line) for line in stream]