Skip to content

Commit a6a5bf8

Browse files
committed
Merge pull request #30 from mateidavid/master
allow user-specified dot character
2 parents e9bc1ad + 8e7e4fa commit a6a5bf8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

data_hacks/bar_chart.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def run(input_stream, options):
6666
scale = int(math.ceil(float(max_value) / value_characters))
6767
scale = max(1, scale)
6868

69-
print "# each represents a count of %d. total %d" % (scale, total)
69+
print "# each " + options.dot + " represents a count of %d. total %d" % (scale, total)
7070

7171
if options.sort_values:
7272
data = [[value, key] for key, value in data.items()]
@@ -85,7 +85,7 @@ def run(input_stream, options):
8585
for value, key in data:
8686
if options.percentage:
8787
percentage = " (%0.2f%%)" % (100 * Decimal(value) / Decimal(total))
88-
print str_format % (key[:max_length], value, (value / scale) * "∎", percentage)
88+
print str_format % (key[:max_length], value, (value / scale) * options.dot, percentage)
8989

9090
if __name__ == "__main__":
9191
parser = OptionParser()
@@ -104,7 +104,8 @@ def run(input_stream, options):
104104
help="sort keys by numeric sequencing")
105105
parser.add_option("-p", "--percentage", dest="percentage", default=False, action="store_true",
106106
help="List percentage for each bar")
107-
107+
parser.add_option("--dot", dest="dot", default='∎', help="Dot representation")
108+
108109
(options, args) = parser.parse_args()
109110

110111
if sys.stdin.isatty():

data_hacks/histogram.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def log_steps(k, n):
241241
print("# Mean = %f; Variance = %f; SD = %f; Median %f" %
242242
(mvsd.mean(), mvsd.var(), mvsd.sd(),
243243
median(accepted_data, key=lambda x: x.value)))
244-
print "# each represents a count of %d" % bucket_scale
244+
print "# each " + options.dot + " represents a count of %d" % bucket_scale
245245
bucket_min = min_v
246246
bucket_max = min_v
247247
percentage = ""
@@ -256,7 +256,7 @@ def log_steps(k, n):
256256
if options.percentage:
257257
percentage = " (%0.2f%%)" % (100 * Decimal(bucket_count) /
258258
Decimal(samples))
259-
print format_string % (bucket_min, bucket_max, bucket_count, '∎' *
259+
print format_string % (bucket_min, bucket_max, bucket_count, options.dot *
260260
star_count, percentage)
261261

262262

@@ -288,6 +288,7 @@ def log_steps(k, n):
288288
help="format for bucket numbers")
289289
parser.add_option("-p", "--percentage", dest="percentage", default=False,
290290
action="store_true", help="List percentage for each bar")
291+
parser.add_option("--dot", dest="dot", default='∎', help="Dot representation")
291292

292293
(options, args) = parser.parse_args()
293294
if sys.stdin.isatty():

0 commit comments

Comments
 (0)