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.4.tar.gz (3.6 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.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for bliplot-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7792b04adb271deabf8d5f8aff5849b6aa1da184ce2be48e1cb3259a1d860c8b
MD5 d2da16fc26188af7268e40b9502efc99
BLAKE2b-256 f9aa57bfc9970b8178060e1c80ea722487ecc2e3ab4669786643db171cc621f9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bliplot-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d44260d1126c00586acbf506f49e9f67c01c6616661f8d772fc44d16edeb027f
MD5 4e3dda042dd5e6fa62a611a4f13c7aab
BLAKE2b-256 d6a1516cccfd74a9150dc676f085fb687de791d66d2ca5eecb0173f6e2f3b809

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