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.
Acknowledgments
Thanks to:
- Alex for inspiring this work with this blog post.
- Jinhang Jiang for the tutorial on how to publish your first Python package.
CHANGELOG
The dates are reported as YYYY-MM-DD.
Version 0.0.1 2022-12-26
- Alpha release
Version 0.0.2 2022-12-26
- Improved readme
Version 0.0.3 2022-12-26
- README: added pip install command
Metadata
Release files for asciibars 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| asciibars-0.0.3.tar.gz | 16.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asciibars-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.3 kB
Release files / asciibars-0.0.3.tar.gz
| Download URL | asciibars-0.0.3.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f71ae8c61b38a0b4eefededaef20763abd83e961ae5c0f6667be816ea2e497ae
|
|
BLAKE2b-256 checksum How to use checksums |
e233ec0ddd6925d9da9ec166218d25c579911f2189afaf5e7262e69fbda023ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / asciibars-0.0.3-py3-none-any.whl
| Download URL | asciibars-0.0.3-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1fc972e1d7376fc9b5c8d2e6f37e113a87cae4da59a15ee4dff367d89a91a2d6
|
|
BLAKE2b-256 checksum How to use checksums |
d78b1b5f9b223169f3e27ca22b6bbf43fafe8d7e24c636f4c7eacbbbf7aa4210
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for asciibars 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.