From ab60f0deefc04732ca08860360994a7b5adfb57f Mon Sep 17 00:00:00 2001 From: Matthew Oliver Date: Tue, 8 Jul 2014 23:48:37 +0000 Subject: [PATCH] Added colour to the edges When the graph gets too big, it is hard to track lines. This patch randomly assigns a colour to each line. The random colour picker picks RGB ranges from 0-200 as 255 (FF) is too light. --- flow.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flow.py b/flow.py index 74813e8..bdde7ed 100755 --- a/flow.py +++ b/flow.py @@ -1,5 +1,6 @@ #!/usr/bin/env python +import random import re import sys @@ -73,12 +74,17 @@ def _add_edge(s1, s2, method, status): def _write_edges(): + def r(): + # FF (255) is a little too light a colour so + # lets shorten the range a big. + return random.randint(0, 200) for edge in edge_tracker.values(): (src, target, method), label, count = edge label = "%dx %s" % (count, label) if label else "%dx" % (count) edge_thickness = float(count) / max_found_edge_weight * max_edge_weight + color = "#%02X%02X%02X" % (r(), r(), r()) g.add_edge(src, target, label=label, weight=count, - penwidth=edge_thickness) + penwidth=edge_thickness, color=color) with open(filename, 'rb') as f: for rawline in f: