@@ -17,7 +17,8 @@ def get_scale(series, is_y=False, steps=20):
1717 min_val = min (series )
1818 max_val = max (series )
1919 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 ):
2122 if x > 0 and scaled_series and max (scaled_series ) < 0 :
2223 scaled_series .append (0.0 )
2324 scaled_series .append (x )
@@ -45,9 +46,13 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
4546 if isinstance (f , str ):
4647 f = open (f )
4748
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
5156 else :
5257 xs = [float (str (row ).strip ()) for row in open (xs )]
5358 ys = [float (str (row ).strip ()) for row in open (ys )]
@@ -65,16 +70,11 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
6570 for (i , (xp , yp )) in enumerate (zip (xs , ys )):
6671 if xp <= x and yp >= y and (xp , yp ) not in plotted :
6772 point = pch
68- #point = str(i)
6973 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 ]
7676 printcolour (point , True , colour )
77- print ("|" )
77+ print (" |" )
7878 print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
7979
8080
0 commit comments