Plot in chars
Project description
chrplotlib
Plot graphs using chars
install:
$pip install chrplotlib --upgrade
For the current developer version:
git clone git@github.com:guofei9987/chrplotlib.git
cd chrplotlib
pip install .
example
from chrplotlib import animation
def update_bar(i):
data = 10 * np.random.rand(20)
print(bar(data, label=range(20), max_height=10))
print('\033[{}A'.format(12))
animation(update_func=update_bar, interval=range(100), pause=0.2)
data = 10 * np.random.rand(20)
label = range(20)
print(bar(data))
Print this:
▃▃
▃▃ ▃▃ ██ ▅▅
██ ▇▇ ██ ██ ▇▇ ██
██ ██ ██ ██ ██ ██
██ ██ ▇▇ ▃▃ ██ ██ ██ ██
██ ██ ▄▄ ▅▅ ██ ██ ██ ██ ██ ██ ▃▃
██ ██ ██ ██ ▂▂ ██ ██ ██ ██ ▃▃ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ▄▄ ██ ██ ██ ██ ▂▂ ██ ▇▇ ██
██ ██ ██ ██ ▃▃ ██ ██ ██ ██ ██ ██ ██ ██ ▃▃ ██ ██ ██ ██ ██ ██
print(bar(data=data, label=range(20)))
Print this:
▃▃
▃▃ ▃▃ ██ ▅▅
██ ▇▇ ██ ██ ▇▇ ██
██ ██ ██ ██ ██ ██
██ ██ ▇▇ ▃▃ ██ ██ ██ ██
██ ██ ▄▄ ▅▅ ██ ██ ██ ██ ██ ██ ▃▃
██ ██ ██ ██ ▂▂ ██ ██ ██ ██ ▃▃ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ▄▄ ██ ██ ██ ██ ▂▂ ██ ▇▇ ██
██ ██ ██ ██ ▃▃ ██ ██ ██ ██ ██ ██ ██ ██ ▃▃ ██ ██ ██ ██ ██ ██
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
print(bar(data, kind='bar'))
Get this:
█▌█▌█▌█▌█▌█▌█▌█▌▌
█▌█▌█▌█▌█▌█▌█▌█▌
█▌█▌█▌█▌▋
█▌█▌█▌█▌█
▌
█▌█▌█▌▎
█▌█▌█▌█▌█▌█▌
█▌█▌█▌█▌█▌▌
█▌█▌█▌█▌█▌█▌█▌█▌▍
█▌▋
█▌█▌
█▌█▌█▌█▌█▌█▌█▌█▌█▌▌
█▌█▌█▌▍
▌
█▌█▌█▌█▌█▌█▌█▌█▌
█▌
█▌▎
█▌█▌█▌█▌█▌█▌█▌█▌█▎
█▌█▌
█▌█▌█▌█▌▌
print(bar(data=data, label=range(20), kind='barh'))
Get this:
0 █▌█▌█▌█▌█▌█▌█▌█▌▌
1 █▌█▌█▌█▌█▌█▌█▌█▌
2 █▌█▌█▌█▌▋
3 █▌█▌█▌█▌█
4 ▌
5 █▌█▌█▌▎
6 █▌█▌█▌█▌█▌█▌
7 █▌█▌█▌█▌█▌▌
8 █▌█▌█▌█▌█▌█▌█▌█▌▍
9 █▌▋
10█▌█▌
11█▌█▌█▌█▌█▌█▌█▌█▌█▌▌
12█▌█▌█▌▍
13▌
14█▌█▌█▌█▌█▌█▌█▌█▌
15█▌
16█▌▎
17█▌█▌█▌█▌█▌█▌█▌█▌█▎
18█▌█▌
19█▌█▌█▌█▌▌
plot images by name
from chrplotlib import img
img_plotter = img.ImagePlotter()
for name in img_plotter.get_all_names():
print(f"name:{name}")
print(img_plotter.from_name(name=name))
Will print this:
plot from image file
from chrplotlib import img
import cv2
import os
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
IMAGE_DIR = os.path.join(CURRENT_DIR, 'data')
img_path = os.path.join(IMAGE_DIR, 'img1.jpeg')
img_data = cv2.imread(img_path)
# print it
print(img.plot_from_img(img_data, max_width=80))
# or save it to .txt file
with open("output.txt", "w") as f:
f.write(img.plot_from_img(img_data, max_width=150))
from this image:
print this:
Plot more images:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chrplotlib-0.1.1.tar.gz
(8.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chrplotlib-0.1.1.tar.gz.
File metadata
- Download URL: chrplotlib-0.1.1.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19c85c55c4056d0ff558c0016da46de00f8c6d143eb5ef2e1f19241565659464
|
|
| MD5 |
3be73d9005f586f8d44cd3f8727abf68
|
|
| BLAKE2b-256 |
cfa7ac121800cabf7eb4606b34e97ad997e13b31289fcd3ca65652ad1bb68fba
|
File details
Details for the file chrplotlib-0.1.1-py3-none-any.whl.
File metadata
- Download URL: chrplotlib-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c9da0dc660c6694d247a50618ab4a844e3c574e6138355d2e1794dc99f929ca
|
|
| MD5 |
5449bd80c9258c3da1bfd4fda7e6cc05
|
|
| BLAKE2b-256 |
60a5940dafe207a571db805e44a56f074c66d6fa2c32b86b3c5f1b8ade268ca2
|