Terminal text-based plotting utility
Project description
bliplot
Stupidly simple terminal graphs. One function with zero config needed and sub-character resolution.
from bliplot import plot
print(plot([1, 4, 2, 8, 5, 7, 3, 9, 6]))
That's it. That's the whole API.
Why
Every terminal-plotting library makes you learn its DSL before you can see a
single number. bliplot is one function that takes a list and gives you back
a string. Print it, log it, pipe it, stream it... It doesn't care. It's yours !
Install
pip install bliplot
or, if you're using uv:
uv add bliplot
Usage
import math
from bliplot import plot
def generate_waveform(x: float) -> float:
return math.sin(x / 10) * math.cos(x / 5) * 10
data_points = [generate_waveform(x) for x in range(100)]
graph = plot(data_points, width=70, height=15, color="CYAN")
print(graph)
Live / streaming graphs
Because plot() just returns a string, you can call it in a loop for a
live-updating graph. No special "live mode" needed:
import math
import time
from bliplot import plot
CLEAR = "\033[H\033[J"
WIDTH = 80
HEIGHT = 15
# We run this for 200 frames of animation
for t in range(200):
lst = []
for x in range(WIDTH):
# Moving the x offset by t * 0.2 causes the wave to travel left to right
x_moving = x - (t * 0.2)
# Base wave + high frequency noise
wave = math.sin(x_moving * 0.2) * math.cos(x_moving * 0.05)
noise = 0.2 * math.sin(x_moving * 1.5)
# Center envelope to keep the edges clean
envelope = math.exp(-((x - (WIDTH / 2)) / (WIDTH / 3)) ** 2)
lst.append((wave + noise) * envelope)
# Overwrite the screen
print(
CLEAR + plot(lst, width=WIDTH, height=HEIGHT, color="GREEN"), end="", flush=True
)
time.sleep(0.04) # ~25 frames per second
The clear-screen escape redraws the graph in place instead of scrolling a new one down the terminal on every iteration.
Parameters
plot(lst: list, width: int = None, height: int = None, color: str = None) -> str
| Param | Type | Default | Description |
|---|---|---|---|
lst |
list | — | Y values to plot. X values are inferred from index. |
width |
int | terminal width | Graph width in characters. |
height |
int | terminal height | Graph height in characters. |
color |
str | None (renders as white) |
One of RESET, GREEN, CYAN, YELLOW, RED, MAGENTA, BLUE, WHITE, BLACK. |
Returns a string, ready to print().
NaN, +Inf, and -Inf values in lst are treated as 0.
How it works
Terminal graphs are usually blocky because each character cell can only be
"on" or "off" so you lose all the resolution between one row of blocks and
the next. bliplot fixes this by spliting each value into an integer part and a fractional
remainder. The integer part decides how many full blocks (█) to stack.
The remainder picks which of the 8 partial block glyphs
(▁▂▃▄▅▆▇█) caps the column, giving you roughly 8x the vertical resolution.
Negative values use the upper-eighth block set (▔🮂🮃▀🮄🮅🮆█) so bars
growing downward from the midline look correct rather than upside-down.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 bliplot-0.1.3.tar.gz.
File metadata
- Download URL: bliplot-0.1.3.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b857fadf2f5775b8738953d5c394982c614c281b5ecbd33266962cc817a1cca
|
|
| MD5 |
76f0f07e8de0932526d70eb491c8e5e8
|
|
| BLAKE2b-256 |
f3f582f1c03dca1c749dc8858a50c5b1963a260bc92833fb58e58c3f12b106bc
|
File details
Details for the file bliplot-0.1.3-py3-none-any.whl.
File metadata
- Download URL: bliplot-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71db802f7a6043d62d9265c03cac4ac105b5f6eba5e7cfb7e0d5d337d4c3b49f
|
|
| MD5 |
4a395b3a5b5c6cb64c7c2d3d056414ac
|
|
| BLAKE2b-256 |
5c64f809ef04d1ae4791c6484dbbdfc053ea653fe38ac80f7d10ca7c7153d7ce
|