Commit 08765297 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

croposp [FEATURE]: support selection of curves

parent 95f52841
......@@ -26,7 +26,7 @@
# 14/02/2019 V1.1 first version providing reasonable functionality
#
# ============================================================================
__version__ = "croposplot 2019-02-14 V1.1"
__version__ = "croposplot 2019-02-15 V1.2"
__author__ = "Thomas Forbriger"
# ----------------------------------------------------------------------------
# backend
......@@ -63,7 +63,7 @@ def usage():
print(' [--legfontsize s] [--legpos p] [--title t]')
print(' [--xlabel l] [--ylabel l] [--titfontsize t]')
print(' [--xlim l] [--ylim l]')
print(' [--usemarkers]')
print(' [--usemarkers] [--match re]')
print(' file [file [file ...]]')
print(' or: '+sys.argv[0]+' --help|-h')
......@@ -95,6 +95,8 @@ def help():
--titfontsize s set font size for legend
--xlim min:max set x-axis limits
--ylim min:max set y-axis limits
--match re only display curve for which the label matches the regular
expression "re"
""")
# -----------------------------------------------------------------------------
......@@ -120,7 +122,7 @@ def main(argv=None):
opts, args=getopt.getopt(sys.argv[1:], 'hvo:g', ['help', 'nologlog',
'nologx', 'nology', 'grid', 'xlabel=', 'legfontsize=', 'title=',
'legpos=', 'titfontsize=', 'ylabel=', 'xlim=', 'ylim=',
'usemarkers'])
'usemarkers', 'match='])
except getopt.GetoptError as err:
print(err.msg)
exit(0)
......@@ -142,6 +144,7 @@ def main(argv=None):
opt_xlim = None
opt_ylim = None
opt_usemarkers = False
opt_match = None
for (opt, arg) in opts:
if opt == '-v':
......@@ -164,6 +167,8 @@ def main(argv=None):
raise
except:
raise Error("Invalid 'ylim' argument.")
elif opt in ('--match'):
opt_match=arg
elif opt in ('--xlabel'):
xlabel=arg
elif opt in ('--ylabel'):
......@@ -235,7 +240,7 @@ def main(argv=None):
if opt_ylim is not None:
plt.ylim(opt_ylim[0], opt_ylim[1])
mymarkers=['o','*','p','v','<','>','P','X','d','D','.']
mymarkers=['o','*','p','v','<','>','d','D','.']
icurve=0
for specfile in args:
......@@ -248,6 +253,10 @@ def main(argv=None):
data=np.loadtxt(specfile, unpack=False)
for i in range(1,len(data[0,:])):
label=re.sub('^# #\d+: ', '', labellines[i-1].strip())
match=True
if opt_match is not None:
match=(re.search(opt_match, label) is not None)
if match:
if verbose:
print('plot curve %d: %s' % (i, label))
themarker=None
......
......@@ -248,7 +248,8 @@ psd%foutra.xxx: psd%.001.asc
CROPOSPLOT=../croposplot.py
# common options
CROPOSPLOT_OPT=--usemarkers
CROPOSPLOT_MATCH=.
CROPOSPLOT_OPT=--usemarkers --match='$(CROPOSPLOT_MATCH)'
# ----------------------------------------------------------------------
# reference plots
......
Markdown is supported
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