{"id":22296157,"url":"https://github.com/kakwa/py-ascii-graph","last_synced_at":"2025-04-07T05:09:35.659Z","repository":{"id":6718462,"uuid":"7964216","full_name":"kakwa/py-ascii-graph","owner":"kakwa","description":"A simple python lib to print data as ascii histograms","archived":false,"fork":false,"pushed_at":"2021-10-29T21:06:18.000Z","size":147,"stargazers_count":117,"open_issues_count":4,"forks_count":17,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-21T14:59:54.225Z","etag":null,"topics":["ascii","chart","graph","histogram","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kakwa.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-01T18:58:35.000Z","updated_at":"2024-05-16T08:47:12.000Z","dependencies_parsed_at":"2022-07-11T00:46:29.108Z","dependency_job_id":null,"html_url":"https://github.com/kakwa/py-ascii-graph","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakwa%2Fpy-ascii-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakwa%2Fpy-ascii-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakwa%2Fpy-ascii-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kakwa%2Fpy-ascii-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kakwa","download_url":"https://codeload.github.com/kakwa/py-ascii-graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595334,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ascii","chart","graph","histogram","python"],"created_at":"2024-12-03T17:44:25.079Z","updated_at":"2025-04-07T05:09:35.638Z","avatar_url":"https://github.com/kakwa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"py-ascii-graph\n==============\n\nA simple python lib to print data as ascii histograms\n\n.. image:: https://github.com/kakwa/py-ascii-graph/actions/workflows/tests.yml/badge.svg\n    :target: ttps://github.com/kakwa/py-ascii-graph/actions/workflows/tests.yml\n    :alt: Python Tests\n    \n.. image:: https://img.shields.io/pypi/v/ascii_graph.svg\n    :target: https://pypi.python.org/pypi/ascii_graph\n    :alt: PyPI version\n\n.. image:: https://badges.gitter.im/Join%20Chat.svg\n    :alt: Join the chat at https://gitter.im/kakwa/py-ascii-graph\n    :target: https://gitter.im/kakwa/py-ascii-graph?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge\n\n.. image:: https://coveralls.io/repos/kakwa/py-ascii-graph/badge.svg?branch=master \n    :target: https://coveralls.io/r/kakwa/py-ascii-graph?branch=master\n\n.. image:: https://readthedocs.org/projects/py-ascii-graph/badge/?version=latest\n    :target: http://py-ascii-graph.readthedocs.org/en/latest/?badge=latest\n    :alt: Documentation Status\n\n.. .. image:: https://img.shields.io/pypi/pyversions/ascii_graph.svg\n..    :target: https://pypi.python.org/pypi/ascii_graph\n..    :alt: Supported Python Versions\n\n----\n\n:Git: `Github \u003chttps://github.com/kakwa/py-ascii-graph\u003e`_\n:PyPI: `Package \u003chttps://pypi.python.org/pypi/ascii_graph\u003e`_\n:Doc: `Documentation \u003chttp://py-ascii-graph.readthedocs.org\u003e`_\n:License: MIT\n:Author: Pierre-Francois Carpentier - copyright 2014\n\n----\n\nLicense\n=======\n\npy-ascii-graph is released under the MIT License.\n\nDescription\n===========\n\npy-ascii-graph is a simple python library to build ascii histograms. \nJust give it a label and a list of tuples (description, value) \nand it will automaticaly creates a nice histogram, \nwith all the stuff aligned and fitting in a fixed width line (if possible).\n\npy-ascii-graph although comes with a command line utility.\n\nExamples\n========\n\nLibrary\n-------\n\nSimple example:\n\n.. sourcecode:: python\n\n    from ascii_graph import Pyasciigraph\n\n    test = [('long_label', 423), ('sl', 1234), ('line3', 531), \n        ('line4', 200), ('line5', 834)]\n\n    graph = Pyasciigraph()\n    for line in  graph.graph('test print', test):\n        print(line)\n\nResult:\n\n.. sourcecode:: bash\n\n    test print\n    ###############################################################################\n    ████████████████████                                            423  long_label\n    █████████████████████████████████████████████████████████████  1234  sl        \n    ██████████████████████████                                      531  line3     \n    █████████                                                       200  line4     \n    █████████████████████████████████████████                       834  line5\n\nComplex examples (colors, different spacing, no label...):\n\n.. sourcecode:: python\n\n    from ascii_graph import Pyasciigraph\n    from ascii_graph.colors import *\n    from ascii_graph.colordata import vcolor\n    from ascii_graph.colordata import hcolor\n    \n    test = [('long_label', 423), ('sl', 1234), ('line3', 531),\n        ('line4', 200), ('line5', 834)]\n    \n    # One color per line\n    print('Color example:')\n    pattern = [Gre, Yel, Red]\n    data = vcolor(test, pattern)\n    \n    graph = Pyasciigraph()\n    for line in graph.graph('vcolor test', data):\n        print(line)\n    \n    # Multicolor on one line\n    print('\\nMultiColor example:')\n    \n    # Color lines according to Thresholds\n    thresholds = {\n      51:  Gre, 100: Blu, 350: Yel, 500: Red,\n    }\n    data = hcolor(test, thresholds)\n    \n    # graph with colors, power of 1000, different graph symbol,\n    # float formatting and a few tweaks\n    graph = Pyasciigraph(\n        line_length=120,\n        min_graph_length=50,\n        separator_length=4,\n        multivalue=False,\n        human_readable='si',\n        graphsymbol='*',\n        float_format='{0:,.2f}',\n        force_max_value=2000,\n        )\n    \n    for line in graph.graph(label=None, data=data):\n        print(line)\n\nCommand Line Utility\n--------------------\n\ncommand line:\n\n.. sourcecode:: bash\n\n    $ asciigraph -h\n    Usage: asciigraph [-l \u003clabel\u003e] [-f file] [-s inc|dec] \\\n       [-c] [-t \u003cfirst color threshold\u003e [-T \u003csecond color threshold\u003e] \\\n       [-w \u003cnumber of char\u003e] [-m \u003cmin len of char\u003e] [-H] [-M cs|si]\n    \n    examples:\n       printf 'label1:10\\nlabel2:100\\n' | asciigraph -l 'my graph'\n       printf 'label1:1000\\nlabel2:20000\\n' | asciigraph -l 'my graph' -H -M 'si'\n       printf 'l1:100\\nl2:1200.42\\n' \u003e ./mf; asciigraph -l 'my graph' -f ./mf\n       asciigraph -l 'my graph' -f mf -s inc\n       asciigraph -l 'my graph' -f mf -s dec -w 60 -m 10\n       asciigraph -l 'my graph' -f mf -c -F '{0:,.2f}'\n       asciigraph -l 'my graph' -f mf -c -t 5 -T 50\n    \n    \n    Options:\n      -h, --help            show this help message and exit\n      -f FILE, --file=FILE  import data from FILE (one data per line,\n                            format: \u003clabel\u003e:\u003cvalue\u003e)\n      -s SORT, --sort=SORT  sort type: inc (increasing) or dec (decreasing)\n      -l LAB, --label=LAB   label of the graph\n      -w WIDTH, --width=WIDTH\n                            width of the graph\n      -m LEN, --min_graph=LEN\n                            minimum length of the graph bar\n      -c, --color           Color the graph\n      -t TC1, --threshold-1=TC1\n                            first color threshold, only make sense if --color is\n                            passed\n      -T TC2, --threshold-2=TC2\n                            second color threshold, only make sense if --color is\n                            passed\n      -H, --human-readable  enable human readable mode (K, M, G, etc)\n      -M HR_MODE, --human-readable-mode=HR_MODE\n                            Human readable mode ('cs' -\u003e power of 1024 or 'si' -\u003e\n                            power of 1000, default: cs)\n      -F FORMAT, --float-format=FORMAT\n                            float formatting, ex: {0:,.2f}\n\n\nSee the examples/ directory for more examples.\n\nInstallation\n============\n\n.. sourcecode:: bash \n\n    $ pip install ascii_graph\n\nor\n\n.. sourcecode:: bash\n\n    $ easy_install ascii_graph\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkakwa%2Fpy-ascii-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkakwa%2Fpy-ascii-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkakwa%2Fpy-ascii-graph/lists"}