From 0405a4f9702ccaec7d84e5d3f2afafbd3a5eba2d Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Tue, 12 Jul 2016 13:42:24 +0200 Subject: [PATCH] tsplot: no -x behaviour fix, module version check * Do not try to plot excluded points if there is no excluded time series to plot. * Perform runtime check on matplotlib version for early exit in case of mismatch. --- scripts/tsplot.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/tsplot.py b/scripts/tsplot.py index 3a811da1..8324f344 100755 --- a/scripts/tsplot.py +++ b/scripts/tsplot.py @@ -1,4 +1,5 @@ #!env python +#coding: utf-8 import argparse import json @@ -8,8 +9,15 @@ import re import logging import matplotlib as M import matplotlib.pyplot as P +from distutils.version import LooseVersion from itertools import chain, islice, cycle +# Run-time check for matplot lib version for line style functionality. +if LooseVersion(M.__version__)<LooseVersion("1.5.0"): + logging.critical("require matplotlib version ≥ 1.5.0") + sys.exit(1) + + # Read timeseries data from multiple files, plot each in one planel, with common # time axis, and optionally sharing a vertical axis as governed by the configuration. @@ -25,7 +33,7 @@ def parse_clargs(): P = argparse.ArgumentParser(description='Plot time series data on one or more graphs.') P.add_argument('inputs', metavar='FILE', nargs='+', help='time series data in JSON format') - P.add_argument('-t', '--abscissae', metavar='RANGE', dest='trange', + P.add_argument('-t', '--trange', metavar='RANGE', dest='trange', type=parse_range_spec, help='restrict time axis to RANGE (see below)') P.add_argument('-g', '--group', metavar='KEY,...', dest='groupby', @@ -313,8 +321,9 @@ def plot_plots(plot_groups, save=None): plot.plot(s.t, s.y, color=c, ls=line, label=l) # treat exluded points especially ex = s.excluded() - ymin, ymax = s.yrange() - plot.plot(ex.t, np.clip(ex.y, ymin, ymax), marker='x', ls='', color=c) + if ex is not None: + ymin, ymax = s.yrange() + plot.plot(ex.t, np.clip(ex.y, ymin, ymax), marker='x', ls='', color=c) if first_plot: plot.legend(loc=2, fontsize='small') -- GitLab