@@ -49,7 +49,7 @@ def _plot_scatter(xs, ys, size, pch, colour, title, cs):
49
49
print (" |" )
50
50
print ("-" * (2 * len (get_scale (xs , False , size )) + 2 ))
51
51
52
- def plot_scatter (f , xs , ys , size , pch , colour , title ):
52
+ def plot_scatter (f , xs , ys , size , pch , colour , title , delimiter = ',' ):
53
53
"""
54
54
Form a complex number.
55
55
@@ -66,9 +66,9 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
66
66
if f :
67
67
if isinstance (f , str ):
68
68
with open (f ) as fh :
69
- data = [tuple (line .strip ().split (',' )) for line in fh ]
69
+ data = [tuple (line .strip ().split (delimiter )) for line in fh ]
70
70
else :
71
- data = [tuple (line .strip ().split (',' )) for line in f ]
71
+ data = [tuple (line .strip ().split (delimiter )) for line in f ]
72
72
xs = [float (i [0 ]) for i in data ]
73
73
ys = [float (i [1 ]) for i in data ]
74
74
if len (data [0 ]) > 2 :
@@ -90,6 +90,7 @@ def main():
90
90
parser = optparse .OptionParser (usage = scatter ['usage' ])
91
91
92
92
parser .add_option ('-f' , '--file' , help = 'a csv w/ x and y coordinates' , default = None , dest = 'f' )
93
+ parser .add_option ('-d' , '--delimiter' , help = 'delimiter between x & y values in input file' , default = ',' )
93
94
parser .add_option ('-t' , '--title' , help = 'title for the chart' , default = "" , dest = 't' )
94
95
parser .add_option ('-x' , help = 'x coordinates' , default = None , dest = 'x' )
95
96
parser .add_option ('-y' , help = 'y coordinates' , default = None , dest = 'y' )
@@ -104,7 +105,7 @@ def main():
104
105
opts .f = sys .stdin .readlines ()
105
106
106
107
if opts .f or (opts .x and opts .y ):
107
- plot_scatter (opts .f , opts .x , opts .y , opts .size , opts .pch , opts .colour , opts .t )
108
+ plot_scatter (opts .f , opts .x , opts .y , opts .size , opts .pch , opts .colour , opts .t , opts . delimiter )
108
109
else :
109
110
print ("nothing to plot!" )
110
111
0 commit comments