Skip to content

Commit fad5daf

Browse files
author
Director of Analytics
committed
updated help
1 parent 6bdf043 commit fad5daf

5 files changed

Lines changed: 19 additions & 9 deletions

File tree

bin/hist.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/python
22
import math
3-
from collections import Counter
43
import optparse
54
import sys
65
from utils.helpers import *
7-
6+
from utils.commandhelp import hist
87

98
def calc_bins(n, min_val, max_val, h=None):
109
"calculate number of bins for the histogram"
@@ -47,7 +46,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title=""):
4746
for number in read_numbers(f):
4847
for i, b in enumerate(bins):
4948
if number < b:
50-
hist[i-1] += 1
49+
hist[i] += 1
5150
# print "breaking"
5251
break
5352

@@ -57,7 +56,6 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title=""):
5756
ys.reverse()
5857

5958
nlen = max(len(str(min_y)), len(str(max_y))) + 1
60-
nlen = 20
6159
print title.center(len(hist) + nlen + 1)
6260
print
6361
used_labs = set()
@@ -67,7 +65,7 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title=""):
6765
ylab = ""
6866
else:
6967
used_labs.add(ylab)
70-
ylab += " "*(nlen - len(ylab)) + "|"
68+
ylab = " "*(nlen - len(ylab)) + ylab + "|"
7169

7270
print ylab,
7371

@@ -110,7 +108,8 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title=""):
110108

111109
if __name__=="__main__":
112110

113-
parser = optparse.OptionParser()
111+
parser = optparse.OptionParser(usage=hist['usage'])
112+
114113
parser.add_option('-f', '--file', help='a file containing a column of numbers',
115114
default=None, dest='f')
116115
parser.add_option('-t', '--title', help='title for the chart',
@@ -120,11 +119,12 @@ def plot_hist(f, height=20.0, bincount=None, pch="o", colour="white", title=""):
120119
parser.add_option('-s', '--height', help='height of the histogram (in lines)',
121120
type='int', default=20., dest='h')
122121
parser.add_option('-p', '--pch', help='shape of each bar', default='o', dest='p')
123-
parser.add_option('-c', '--colour', help='colour of the plot (%s)' % ", ".join(bcolours.keys()),
122+
parser.add_option('-c', '--colour', help='colour of the plot (%s)' % ", ".join([c for c in bcolours.keys() if c !=
123+
'ENDC']),
124124
default='white', dest='colour')
125125

126126
(opts, args) = parser.parse_args()
127-
127+
128128
if opts.f is None:
129129
if len(args) > 0:
130130
opts.f = args[0]

bin/scatter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import optparse
44
from utils.helpers import *
55
import sys
6+
from helpers.commandhelp import scatter
67

78

89
def get_scale(series, is_y=False, steps=20):
@@ -59,7 +60,7 @@ def plot_scatter(f, xs, ys, size, pch, colour, title):
5960

6061
if __name__=="__main__":
6162

62-
parser = optparse.OptionParser()
63+
parser = optparse.OptionParser(usage=scatter['usage'])
6364
parser.add_option('-f', '--file', help='a csv w/ x and y coordinates',
6465
default=None, dest='f')
6566
parser.add_option('-t', '--title', help='title for the chart',

bin/utils/commandhelp.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
hist = {
3+
"usage": "this is a histogram"
4+
}
5+
6+
scatter = {
7+
"usage": "this is a scatterplot"
8+
}
9+

bin/utils/commandhelp.pyc

250 Bytes
Binary file not shown.

bin/utils/helpers.pyc

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)