Skip to main content

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]))

first example

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)

waveform

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

live render

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bliplot-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bliplot-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file bliplot-0.1.0.tar.gz.

File metadata

  • Download URL: bliplot-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 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

Hashes for bliplot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c5b22d9029bb09c233c218010e521930b6c499f8085d8ba27fab655e852e5e8
MD5 3ebde3abb761a7a483fc817a256f368f
BLAKE2b-256 eeb0feb7bd65c639f8f03781812eec8e1433b7b09aeecf622f314eea2e22bb7b

See more details on using hashes here.

File details

Details for the file bliplot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: bliplot-0.1.0-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

Hashes for bliplot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57d020167ec2d30f8d4310ce08dcca656a506de91a20d17e66d2588340f3dfb0
MD5 51a3dd0b60b9921906e3554fadfc10b7
BLAKE2b-256 f04eadf0cac6c901c98e27599d1a7b3e04f7b848bb22176b0a1477733b706aea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page