Sparklines (Text-based Unicode)
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
- gotcha Sparklines generated by this library are purely text-based using Unicode characters. Their visual representation is heavily dependent on the terminal, console, or font used for display. Inconsistent font support or terminal settings can lead to misaligned or incorrect rendering.
- gotcha While negative values are technically supported, the visual representation can be misleading. Since the sparkline uses character heights to denote magnitude, negative values might not intuitively convey 'below zero' compared to graphical charts. The output is optimized for positive ranges.
- gotcha Achieving 'true' sparklines that appear as smooth lines rather than character-block patterns is challenging with this text-only approach. Unicode character limitations mean that highly granular or continuous line representations are not possible without dedicated font support, which is outside the scope of this tool.
Install
-
pip install sparklines
Imports
- sparklines
from sparklines import sparklines
Quickstart
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)