Commit 87284c78 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [WP]: plot curve legend

parent 5be6954f
......@@ -47,6 +47,7 @@ import sys
import os
import getopt
import string
import re
import numpy as np
import matplotlib.pyplot as plt
......@@ -56,7 +57,9 @@ def usage():
print usage information
print('Usage: '+sys.argv[0]+' [-v] file [file [file ...]]')
print('Usage: '+sys.argv[0]+' [-v]')
print(' [-o file] [-g|--grid] [--nologlog] [--nologx] [--nology]')
print(' file [file [file ...]]')
print(' or: '+sys.argv[0]+' --help|-h')
......@@ -71,9 +74,14 @@ def help():
Read multicolumn output files of spectral values as written by croposp and
create graphical diagrams.
file ... multicolumn spectral data output of croposp
-v be verbose
-o file write to file
file ... multicolumn spectral data output of croposp
-v be verbose
-o file write to file
--xlabel l set label "l" on x-axis
-g|--grid plot grid
--nologlog plot on linear scales
--nologx use linear scale for x-axis
--nology use linear scale for y-axis
# ============================================================================
......@@ -88,7 +96,7 @@ def main(argv=None):
opts, args=getopt.getopt(sys.argv[1:], 'hvo:g', ['help', 'nologlog',
'nologx', 'nology', 'grid'])
'nologx', 'nology', 'grid', 'xlabel'])
except getopt.GetoptError as err:
......@@ -101,6 +109,7 @@ def main(argv=None):
nologx = False
nology = False
grid = False
xlabel = 'frequency / Hz'
for (opt, arg) in opts:
if opt == '-v':
......@@ -109,6 +118,8 @@ def main(argv=None):
elif opt == '-o':
elif opt in ('--xlabel'):
elif opt in ("-g", "--grid"):
grid = True
elif opt in ("--nologlog"):
......@@ -158,14 +169,22 @@ def main(argv=None):
if verbose:
sys.stdout.write("specplot: Disable logscale ... \n")
for specfile in args:
if verbose:
print('read file %s' % specfile)
# read trace labels
labellines=list(filter((lambda x: re.match('^# #',x)),
# read trace data
data=np.loadtxt(specfile, unpack=False)
for i in range(1,len(data[0,:])):
label=re.sub('^# #\d+: ', '', labellines[i-1].strip())
if verbose:
print('plot curve %d' % i)
plt.plot(data[:,0], data[:,i])
print('plot curve %d: %s' % (i, label))
plt.plot(data[:,0], data[:,i], label=label)
if outfile=='x11':
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment