Skip to content

ASCII bar graph with major and minor grid (▉▉▊▉▍)

Notifications You must be signed in to change notification settings

brandm/ascii_bar_graph_with_grid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

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.

About

ASCII bar graph with major and minor grid (▉▉▊▉▍)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages