From 81f3b3aafe72e5ca9ac79d29246e70dce76ebca9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 12 Jan 2016 15:04:55 +0100 Subject: TOOLS/stats-conv: slightly better color pyqtgraph's intColor() is less than ideal, especially on white background. Can't see anything. Unfortunately the rendering of the legend can't be fixed, because pyqtgraph is terrible and hardcodes its rendering, including colors. --- TOOLS/stats-conv.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'TOOLS/stats-conv.py') diff --git a/TOOLS/stats-conv.py b/TOOLS/stats-conv.py index e0b168d541..120f69195a 100755 --- a/TOOLS/stats-conv.py +++ b/TOOLS/stats-conv.py @@ -40,7 +40,7 @@ class G: events = {} start = None markers = ["o", "s", "t", "d"] - curveno = 0 + curveno = {} def find_marker(): if len(G.markers) == 0: @@ -66,6 +66,10 @@ def get_event(event, evtype): G.events[event] = e return G.events[event] +colors = [(0.0, 0.5, 0.0), (0.0, 0.0, 1.0), (0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.75, 0.75, 0), (0.0, 0.75, 0.75), (0.75, 0, 0.75)] +def mkColor(t): + return pg.mkColor(int(t[0] * 255), int(t[1] * 255), int(t[2] * 255)) + SCALE = 1e6 # microseconds to seconds for line in [line.split("#")[0].strip() for line in open(filename, "r")]: @@ -152,8 +156,10 @@ for e in G.sevents: args['symbol'] = e.marker args['pen'] = None else: - args['pen'] = pg.mkPen(pg.intColor(G.curveno), width=0) - G.curveno += 1 + if not cur in G.curveno: + G.curveno[cur] = 0 + args['pen'] = pg.mkPen(mkColor(colors[G.curveno[cur] % len(colors)]), width=0) + G.curveno[cur] += 1 n = cur.plot([x for x,y in e.vals], [y for x,y in e.vals], **args) QtGui.QApplication.instance().exec_() -- cgit v1.2.3