1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#!/usr/bin/env python3
import fileinput
import numpy
import pylab
import sys
text = []
columns = []
for line in fileinput.input(encoding='utf-8'):
line = line.strip()
if line.startswith('#'):
columns = line.replace('#', '').split(',')
continue
text.append(line)
data = numpy.genfromtxt(text, dtype=float, delimiter=',')
if len(data.shape) == 1:
data = data[:,numpy.newaxis]
if not columns:
columns = [None] * data.shape[1]
fig, axs = pylab.subplots(len(columns), 1, sharex=True)
if len(columns) == 1:
axs = [axs]
for col_idx, col_name in enumerate(columns):
axs[col_idx].ticklabel_format(style='plain')
if col_name:
axs[col_idx].set_title(col_name)
axs[col_idx].grid()
axs[col_idx].plot(data[:,col_idx], '-*')
pylab.show()
|