@@ -31,12 +31,14 @@ def get_scale(series, is_y=False, steps=20):
3131def _plot_scatter (xs , ys , size , pch , colour , title , cs ):
3232 plotted = set ()
3333
34+ plot_str = ""
35+
3436 if title :
35- print ( box_text (title , 2 * (len (get_scale (xs , False , size )) + 1 ) ))
37+ plot_str += box_text (title , 2 * (len (get_scale (xs , False , size )) + 1 ))
3638
37- print ( "-" * (2 * (len (get_scale (xs , False , size )) + 2 ) ))
39+ plot_str += "-" * (2 * (len (get_scale (xs , False , size )) + 2 ))
3840 for y in get_scale (ys , True , size ):
39- print ( "|" , end = ' ' )
41+ plot_str += "|"
4042 for x in get_scale (xs , False , size ):
4143 point = " "
4244 for (i , (xp , yp )) in enumerate (zip (xs , ys )):
@@ -46,8 +48,10 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs):
4648 if cs :
4749 colour = cs [i ]
4850 printcolour (point + " " , True , colour )
49- print (" |" )
50- print ("-" * (2 * (len (get_scale (xs , False , size )) + 2 )))
51+ plot_str += " |"
52+
53+ plot_str += "-" * (2 * (len (get_scale (xs , False , size )) + 2 ))
54+ return plot_str
5155
5256def plot_scatter (f , xs , ys , size , pch , colour , title ):
5357 """
@@ -81,7 +85,7 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
8185 with open (ys ) as fh :
8286 ys = [float (str (row ).strip ()) for row in fh ]
8387
84- _plot_scatter (xs , ys , size , pch , colour , title , cs )
88+ print _plot_scatter (xs , ys , size , pch , colour , title , cs )
8589
8690
8791
0 commit comments