Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 2.57 KB

README.org

File metadata and controls

52 lines (42 loc) · 2.57 KB

Summary

Python 3 module to draw an ASCII bar graph with optional major and minor grid.

Some examples with a major grid every 100 and a minor grid every 20:

#                                   0        100       200       300
bar_graph( 98, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊                     '
bar_graph( 99, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▉                     '
bar_graph(100, 10, 31, 2, 5)  # => '█▉█▉█▉█▉██                     '
bar_graph(101, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▏                    '
bar_graph(102, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▎                    '
bar_graph(104, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▍                    '
bar_graph(105, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▌                    '
bar_graph(106, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▋                    '
bar_graph(107, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▊                    '
bar_graph(109, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊▉                    '
bar_graph(110, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊█                    '
bar_graph(120, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊██                   '
bar_graph(140, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊█▉██                 '
bar_graph(160, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊█▉█▉██               '
bar_graph(200, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊█▉█▉█▉█▉██           '
bar_graph(300, 10, 31, 2, 5)  # => '█▉█▉█▉█▉█▊█▉█▉█▉█▉█▊█▉█▉█▉█▉██ '

See also the examples for the unit tests of the function bar_graph in the source file for indication of under- and overflow and more. There is also orgtbl_ascii_draw, a Python reimplementation of the Emacs Lisp function orgtbl-ascii-draw from Emacs Org mode.