@@ -28,6 +28,27 @@ def get_scale(series, is_y=False, steps=20):
28
28
return scaled_series
29
29
30
30
31
+ def _plot_scatter (xs , ys , size , pch , colour , title , cs ):
32
+ plotted = set ()
33
+
34
+ if title :
35
+ print (box_text (title , 2 * len (get_scale (xs , False , size )) + 1 ))
36
+
37
+ print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
38
+ for y in get_scale (ys , True , size ):
39
+ print ("|" , end = ' ' )
40
+ for x in get_scale (xs , False , size ):
41
+ point = " "
42
+ for (i , (xp , yp )) in enumerate (zip (xs , ys )):
43
+ if xp <= x and yp >= y and (xp , yp ) not in plotted :
44
+ point = pch
45
+ plotted .add ((xp , yp ))
46
+ if cs :
47
+ colour = cs [i ]
48
+ printcolour (point , True , colour )
49
+ print (" |" )
50
+ print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
51
+
31
52
def plot_scatter (f , xs , ys , size , pch , colour , title ):
32
53
"""
33
54
Form a complex number.
@@ -41,7 +62,6 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
41
62
colour -- colour of the points
42
63
title -- title of the plot
43
64
"""
44
-
45
65
cs = None
46
66
if f :
47
67
if isinstance (f , str ):
@@ -53,31 +73,16 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
53
73
ys = [float (i [1 ]) for i in data ]
54
74
if len (data [0 ]) > 2 :
55
75
cs = [i [2 ].strip () for i in data ]
76
+ elif isinstance (xs , list ) and isinstance (ys , list ):
77
+ pass
56
78
else :
57
79
with open (xs ) as fh :
58
80
xs = [float (str (row ).strip ()) for row in fh ]
59
81
with open (ys ) as fh :
60
82
ys = [float (str (row ).strip ()) for row in fh ]
61
83
62
- plotted = set ()
63
-
64
- if title :
65
- print (box_text (title , 2 * len (get_scale (xs , False , size )) + 1 ))
66
-
67
- print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
68
- for y in get_scale (ys , True , size ):
69
- print ("|" , end = ' ' )
70
- for x in get_scale (xs , False , size ):
71
- point = " "
72
- for (i , (xp , yp )) in enumerate (zip (xs , ys )):
73
- if xp <= x and yp >= y and (xp , yp ) not in plotted :
74
- point = pch
75
- plotted .add ((xp , yp ))
76
- if cs :
77
- colour = cs [i ]
78
- printcolour (point , True , colour )
79
- print (" |" )
80
- print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
84
+ _plot_scatter (xs , ys , size , pch , colour , title , cs )
85
+
81
86
82
87
83
88
def main ():
0 commit comments