@@ -30,16 +30,17 @@ def get_scale(series, is_y=False, steps=20):
3030
3131def _plot_scatter (xs , ys , size , pch , colour , title , cs , x_title , y_title ):
3232 plotted = set ()
33+ graph = ""
3334
3435 if title :
35- print ( box_text (title , 2 * (len (get_scale (xs , False , size )) + 1 )))
36+ graph += box_text (title , 2 * (len (get_scale (xs , False , size )) + 1 )) + ' \n '
3637
37- print ( " +" + "-" * (2 * (len (get_scale (xs , False , size )) + 2 ) - 2 ) + "+" )
38+ graph += " +" + "-" * (2 * (len (get_scale (xs , False , size )) + 2 ) - 2 ) + "+\n "
3839 for y in get_scale (ys , True , size ):
3940 if y_title == "" :
40- print ( " |" , end = ' ' )
41+ graph += " | "
4142 else :
42- print ( y_title [:1 ], "|" , end = ' ' )
43+ graph += y_title [:1 ] + " | "
4344 y_title = y_title [1 :]
4445 for x in get_scale (xs , False , size ):
4546 point = " "
@@ -57,10 +58,11 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs, x_title, y_title):
5758 point = "|"
5859 elif y == 0.0 :
5960 point = "-"
60- printcolour (point + " " , True , colour )
61- print (" |" )
62- print (" +" + "-" * (2 * (len (get_scale (xs , False , size )) + 2 ) - 2 ) + "+" )
63- print (" " , x_title )
61+ graph += point + " "
62+ graph += " |\n "
63+ graph += " +" + "-" * (2 * (len (get_scale (xs , False , size )) + 2 ) - 2 ) + "+"
64+ graph += " " + x_title
65+ return graph
6466
6567def plot_scatter (f , xs , ys , size , pch , colour , title , x_title , y_title ):
6668 """
@@ -94,7 +96,8 @@ def plot_scatter(f, xs, ys, size, pch, colour, title, x_title, y_title):
9496 with open (ys ) as fh :
9597 ys = [float (str (row ).strip ()) for row in fh ]
9698
97- _plot_scatter (xs , ys , size , pch , colour , title , cs , x_title , y_title )
99+ graph = _plot_scatter (xs , ys , size , pch , colour , title , cs , x_title , y_title )
100+ print (graph )
98101
99102
100103
0 commit comments