@@ -50,7 +50,7 @@ def run_demo():
5050 print "hist -f ./data/exp.txt -s 35.0 -b 40"
5151 plot_hist ('./data/exp.txt' , height = 35.0 , bincount = 40 )
5252
53- def plot_hist (f , height = 20.0 , bincount = None , pch = "o" , colour = "white" , title = "" , xlab = None ):
53+ def plot_hist (f , height = 20.0 , bincount = None , pch = "o" , colour = "white" , title = "" , xlab = None , nosummary = True ):
5454 "plot a histogram given a file of numbers"
5555 if pch is None :
5656 pch = "o"
@@ -121,16 +121,18 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
121121 print
122122 center = max (map (len , map (str , [n , min_val , mean , max_val ])))
123123 center += 15
124- print
125- print "-" * (2 + center )
126- print "|" + "Summary" .center (center ) + "|"
127- print "-" * (2 + center )
128- summary = "|" + ("observations: %d" % n ).center (center ) + "|\n "
129- summary += "|" + ("min value: %f" % min_val ).center (center ) + "|\n "
130- summary += "|" + ("mean : %f" % mean ).center (center ) + "|\n "
131- summary += "|" + ("max value: %f" % max_val ).center (center ) + "|\n "
132- summary += "-" * (2 + center )
133- print summary
124+
125+ if nosummary is not True :
126+ print
127+ print "-" * (2 + center )
128+ print "|" + "Summary" .center (center ) + "|"
129+ print "-" * (2 + center )
130+ summary = "|" + ("observations: %d" % n ).center (center ) + "|\n "
131+ summary += "|" + ("min value: %f" % min_val ).center (center ) + "|\n "
132+ summary += "|" + ("mean : %f" % mean ).center (center ) + "|\n "
133+ summary += "|" + ("max value: %f" % max_val ).center (center ) + "|\n "
134+ summary += "-" * (2 + center )
135+ print summary
134136
135137
136138if __name__ == "__main__" :
@@ -150,9 +152,10 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
150152 parser .add_option ('-c' , '--colour' , help = 'colour of the plot (%s)' % ", " .join ([c for c in bcolours .keys () if c != 'ENDC' ]),
151153 default = 'white' , dest = 'colour' )
152154 parser .add_option ('-d' , '--demo' , help = 'run demos' , action = 'store_true' , dest = 'demo' )
155+ parser .add_option ('-n' , '--nosummary' , help = 'run demos' , action = 'store_true' , dest = 'nosummary' )
153156
154157 (opts , args ) = parser .parse_args ()
155-
158+
156159 if opts .f is None :
157160 if len (args ) > 0 :
158161 opts .f = args [0 ]
@@ -162,7 +165,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title="",
162165 if opts .demo :
163166 run_demo ()
164167 elif opts .f :
165- plot_hist (opts .f , opts .h , opts .b , opts .p , opts .colour , opts .t , opts .x )
168+ plot_hist (opts .f , opts .h , opts .b , opts .p , opts .colour , opts .t , opts .x , opts . nosummary )
166169 else :
167170 print "nothing to plot!"
168171
0 commit comments