# asciibars
`asciibars` is a Python module for plotting bar charts in ASCII.
## How to install it
```
pip install asciibars
```
## How to use it
Import the module:
```
import asciibars
```
Define your data with both labels and counts:
```
data_p = [
('Gigi', 64 ),
('Carletto', 12 ),
('Silvio', 0 ),
('Priscilla', 30 ),
('Rodolfo', 57 ),
('Sigismondo', 70 )
]
```
Generate your bar chart in ASCII:
```
asciibars.plot(data_p)
```
The command above will print:
```
Gigi | 64 ██████████████████
Carletto | 12 ███
Silvio | 0 ▏
Priscilla | 30 █████████
Rodolfo | 57 ████████████████
Sigismondo | 70 ████████████████████
```
## Arguments of asciibars.plot
| Input | Type | Description |
| ---------- | -------------- | -------------------------------------- |
| data | [(str, float)] | data array with labels and count |
| sep_lc | str | label-count separator |
| unit | str | string unit for bar |
| zero | str | string for bar when equal to zero |
| max_length | int | maximum bar length in plot |
| neg_unit | str | negated bar unit (e.g., '░') |
| neg_max | int | maximum value when negated bar is used |
| count_pf | str | count postfix (e.g., '%') |
## Examples
Please find more examples below.
```
asciibars.plot(data_p,sep_lc=' -> ',unit='▓',max_length=40)
Gigi -> 64 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
Carletto -> 12 ▓▓▓▓▓▓▓
Silvio -> 0 ▏
Priscilla -> 30 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
Rodolfo -> 57 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
Sigismondo -> 70 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
```
```
asciibars.plot(data_p,unit='▓',neg_unit='░')
Gigi | 64 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░
Carletto | 12 ▓▓▓░░░░░░░░░░░░░░░░░
Silvio | 0 ░░░░░░░░░░░░░░░░░░░░
Priscilla | 30 ▓▓▓▓▓▓▓▓▓░░░░░░░░░░░
Rodolfo | 57 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░
Sigismondo | 70 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
```
```
asciibars.plot(data_p,unit='▓',neg_unit='░',neg_max=100,count_pf='%')
Gigi | 64% ▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░
Carletto | 12% ▓▓░░░░░░░░░░░░░░░░░░
Silvio | 0% ░░░░░░░░░░░░░░░░░░░░
Priscilla | 30% ▓▓▓▓▓▓░░░░░░░░░░░░░░
Rodolfo | 57% ▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░
Sigismondo | 70% ▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░
100%
```
```
data_pn = [
('One', 64 ),
('Two', 38 ),
('Three', 0 ),
('Four', -18 ),
('Five', -30 )
]
asciibars.plot(data_pn,sep_lc=' ',count_pf='%')
One 64% ██████████████
Two 38% ████████
Three 0% ▏
Four -18% ████
Five -30% ██████
```
## Change log
Please find the change log [here](CHANGELOG.md).
## Acknowledgments
Thanks to:
- [Alex](https://alexwlchan.net/) for inspiring this work with [this blog post](https://alexwlchan.net/2018/05/ascii-bar-charts/).
- [Jinhang Jiang](https://www.linkedin.com/in/jinhangjiang/) for the tutorial on [how to publish your first Python package](https://towardsdatascience.com/an-end-to-end-guide-to-publish-your-python-package-bdb56639662c).
# CHANGELOG
The dates are reported as YYYY-MM-DD.
## Version 0.0.1 2022-12-26
1. Alpha release
## Version 0.0.2 2022-12-26
1. Improved readme
## Version 0.0.3 2022-12-26
1. README: added pip install command
Raw data
{
"_id": null,
"home_page": "https://github.com/andreabonetti/asciibars",
"name": "asciibars",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Documentation,Bar chart,Plot,Python module,Visualization",
"author": "Andrea Bonetti",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/e2/33/ec0ddd6925d9da9ec166218d25c579911f2189afaf5e7262e69fbda023ef/asciibars-0.0.3.tar.gz",
"platform": null,
"description": "# asciibars\n\n`asciibars` is a Python module for plotting bar charts in ASCII.\n\n## How to install it\n\n```\npip install asciibars\n```\n\n## How to use it\n\nImport the module:\n```\nimport asciibars\n```\n\nDefine your data with both labels and counts:\n```\ndata_p = [\n ('Gigi', 64 ),\n ('Carletto', 12 ),\n ('Silvio', 0 ),\n ('Priscilla', 30 ),\n ('Rodolfo', 57 ),\n ('Sigismondo', 70 )\n]\n```\n\nGenerate your bar chart in ASCII:\n```\nasciibars.plot(data_p)\n```\n\nThe command above will print:\n```\nGigi | 64 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\nCarletto | 12 \u2588\u2588\u2588\nSilvio | 0 \u258f\nPriscilla | 30 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\nRodolfo | 57 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\nSigismondo | 70 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\n```\n\n## Arguments of asciibars.plot\n\n| Input | Type | Description |\n| ---------- | -------------- | -------------------------------------- |\n| data | [(str, float)] | data array with labels and count |\n| sep_lc | str | label-count separator |\n| unit | str | string unit for bar |\n| zero | str | string for bar when equal to zero |\n| max_length | int | maximum bar length in plot |\n| neg_unit | str | negated bar unit (e.g., '\u2591') |\n| neg_max | int | maximum value when negated bar is used |\n| count_pf | str | count postfix (e.g., '%') |\n\n\n## Examples\n\nPlease find more examples below.\n\n\n```\nasciibars.plot(data_p,sep_lc=' -> ',unit='\u2593',max_length=40)\n\nGigi -> 64 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\nCarletto -> 12 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\nSilvio -> 0 \u258f\nPriscilla -> 30 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\nRodolfo -> 57 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\nSigismondo -> 70 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\n```\n\n```\nasciibars.plot(data_p,unit='\u2593',neg_unit='\u2591')\n\nGigi | 64 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\nCarletto | 12 \u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nSilvio | 0 \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nPriscilla | 30 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nRodolfo | 57 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\nSigismondo | 70 \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\n```\n\n```\nasciibars.plot(data_p,unit='\u2593',neg_unit='\u2591',neg_max=100,count_pf='%')\n\nGigi | 64% \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nCarletto | 12% \u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nSilvio | 0% \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nPriscilla | 30% \u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nRodolfo | 57% \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\nSigismondo | 70% \u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2591\u2591\u2591\u2591\u2591\u2591\n 100%\n```\n\n```\ndata_pn = [\n ('One', 64 ),\n ('Two', 38 ),\n ('Three', 0 ),\n ('Four', -18 ),\n ('Five', -30 )\n]\n\nasciibars.plot(data_pn,sep_lc=' ',count_pf='%')\n\nOne 64% \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\nTwo 38% \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\nThree 0% \u258f\nFour -18% \u2588\u2588\u2588\u2588\nFive -30% \u2588\u2588\u2588\u2588\u2588\u2588\n```\n\n## Change log\nPlease find the change log [here](CHANGELOG.md).\n\n## Acknowledgments\nThanks to:\n- [Alex](https://alexwlchan.net/) for inspiring this work with [this blog post](https://alexwlchan.net/2018/05/ascii-bar-charts/).\n- [Jinhang Jiang](https://www.linkedin.com/in/jinhangjiang/) for the tutorial on [how to publish your first Python package](https://towardsdatascience.com/an-end-to-end-guide-to-publish-your-python-package-bdb56639662c).\n\n# CHANGELOG\n\nThe dates are reported as YYYY-MM-DD.\n\n## Version 0.0.1 2022-12-26\n1. Alpha release\n\n## Version 0.0.2 2022-12-26\n1. Improved readme\n\n## Version 0.0.3 2022-12-26\n1. README: added pip install command\n",
"bugtrack_url": null,
"license": "",
"summary": "Bar charts in ASCII",
"version": "0.0.3",
"split_keywords": [
"documentation",
"bar chart",
"plot",
"python module",
"visualization"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "5b346af819966997168171bacc1c2d44",
"sha256": "1fc972e1d7376fc9b5c8d2e6f37e113a87cae4da59a15ee4dff367d89a91a2d6"
},
"downloads": -1,
"filename": "asciibars-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b346af819966997168171bacc1c2d44",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 16553,
"upload_time": "2022-12-26T13:35:09",
"upload_time_iso_8601": "2022-12-26T13:35:09.547856Z",
"url": "https://files.pythonhosted.org/packages/d7/8b/1b5f9b223169f3e27ca22b6bbf43fafe8d7e24c636f4c7eacbbbf7aa4210/asciibars-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "a52a975bc94a4593b85a8ae2bdbc8e40",
"sha256": "f71ae8c61b38a0b4eefededaef20763abd83e961ae5c0f6667be816ea2e497ae"
},
"downloads": -1,
"filename": "asciibars-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "a52a975bc94a4593b85a8ae2bdbc8e40",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 16767,
"upload_time": "2022-12-26T13:35:11",
"upload_time_iso_8601": "2022-12-26T13:35:11.446804Z",
"url": "https://files.pythonhosted.org/packages/e2/33/ec0ddd6925d9da9ec166218d25c579911f2189afaf5e7262e69fbda023ef/asciibars-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-26 13:35:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "andreabonetti",
"github_project": "asciibars",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "asciibars"
}