@@ -17,7 +17,8 @@ def get_scale(series, is_y=False, steps=20): |
17 | 17 | min_val = min(series) |
18 | 18 | max_val = max(series) |
19 | 19 | scaled_series = [] |
20 | | - for x in drange(min_val, max_val, (max_val - min_val) / steps): |
| 20 | + for x in drange(min_val, max_val, (max_val - min_val) / steps, |
| 21 | + include_stop=True): |
21 | 22 | if x > 0 and scaled_series and max(scaled_series) < 0: |
22 | 23 | scaled_series.append(0.0) |
23 | 24 | scaled_series.append(x) |
@@ -45,9 +46,13 @@ def plot_scatter(f, xs, ys, size, pch, colour, title): |
45 | 46 | if isinstance(f, str): |
46 | 47 | f = open(f) |
47 | 48 |
|
48 | | - data = [tuple(map(float, line.strip().split(','))) for line in f] |
49 | | - xs = [i[0] for i in data] |
50 | | - ys = [i[1] for i in data] |
| 49 | + data = [tuple(line.strip().split(',')) for line in f] |
| 50 | + xs = [float(i[0]) for i in data] |
| 51 | + ys = [float(i[1]) for i in data] |
| 52 | + if len(data[0]) > 2: |
| 53 | + cs = [i[2].strip() for i in data] |
| 54 | + else: |
| 55 | + cs = None |
51 | 56 | else: |
52 | 57 | xs = [float(str(row).strip()) for row in open(xs)] |
53 | 58 | ys = [float(str(row).strip()) for row in open(ys)] |
@@ -65,16 +70,11 @@ def plot_scatter(f, xs, ys, size, pch, colour, title): |
65 | 70 | for (i, (xp, yp)) in enumerate(zip(xs, ys)): |
66 | 71 | if xp <= x and yp >= y and (xp, yp) not in plotted: |
67 | 72 | point = pch |
68 | | - #point = str(i) |
69 | 73 | plotted.add((xp, yp)) |
70 | | - if x == 0 and y == 0: |
71 | | - point = "o" |
72 | | - elif x == 0: |
73 | | - point = "|" |
74 | | - elif y == 0: |
75 | | - point = "-" |
| 74 | + if cs: |
| 75 | + colour = cs[i] |
76 | 76 | printcolour(point, True, colour) |
77 | | - print("|") |
| 77 | + print(" |") |
78 | 78 | print("-" * (2 * len(get_scale(xs, False, size)) + 2)) |
79 | 79 |
|
80 | 80 |
|
|