Sparklines (Text-based Unicode)

0.7.0 · active · verified Fri Apr 10

Sparklines is a Python library that generates text-only sparklines using Unicode characters. It's designed for displaying compact, inline visualizations of numerical data, primarily suitable for command-line interfaces or plain text environments. The current version is 0.7.0. Releases are infrequent, focusing on stability and minor enhancements.

Warnings

Install

Imports

Quickstart

The `sparklines` function takes a list of numbers and returns an iterable of strings, each representing a line of the sparkline. You can iterate over these lines to print a multi-line sparkline. Optional arguments allow for customization like setting minimum/maximum values, number of output lines, and character styles.

from sparklines import sparklines

data = [1, 2, 3, 4, 5.0, None, 3, 2, 1, 0, 0, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1]

for line in sparklines(data):
    print(line)

# Example with options
print('\nSparkline with custom range and fill:')
for line in sparklines(data, minimum=0, maximum=5, num_lines=2, fill='█', dot='●'):
    print(line)

view raw JSON →