Registry / data / sparklines

sparklines

JSON →
library1.0.0pypypi✓ verified 24d ago

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.

pip install sparklines
INSTALL
IMPORT
SIG · SPARKLINES
S
sparklines
datapythonv1.0.0
Install
1.8s avg
Import
15ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.016s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.014s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

sparklines
from sparklines import sparklines

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)
sparklines --version
Debug
Known issues
gotchaSparklines 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.
fix
Test rendering in target environments. Ensure a Unicode-compatible font and terminal are used. Consider adjusting `num_lines` for simpler output if display issues persist.
affects: All versions
gotchaWhile 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.
fix
For data with significant negative values, consider normalizing your data to a positive range before passing it to `sparklines`, or use a different visualization library if precise negative value representation is critical. The library can issue warnings for negative values if configured.
affects: All versions
gotchaAchieving '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.
fix
Adjust expectations for text-based visualizations. If smooth, high-resolution line graphs are required, a graphical plotting library (e.g., Matplotlib, Plotly) should be used instead.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'sparklines'
The 'sparklines' library is not installed in the current Python environment.
fix
pip install sparklines
NameError: name 'sparkline' is not defined
After importing the library as 'import sparklines', the main function must be called using the module prefix, i.e., 'sparklines.sparklines()', not 'sparkline()'.
fix
import sparklines
output = sparklines.sparklines([1, 5, 2, 8])
AttributeError: module 'sparklines' has no attribute 'plot'
Developers often expect a 'plot' or 'render' method from charting libraries, but 'sparklines' uses its main function 'sparklines.sparklines()' directly to generate the string output.
fix
from sparklines import sparklines
output = sparklines([1, 5, 2, 8])
TypeError: 'str' object cannot be interpreted as an integer
The 'sparklines' function expects an iterable of numeric values (like a list or tuple of integers or floats), but it received a single string.
fix
from sparklines import sparklines
output = sparklines([1, 5, 2, 8])
Upgrade
Version history
1.0.0latest on PyPI · released Jun 8, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.9 or newer.
Agent activity
12 hits · last 30 days
node
8
OpenAI (training)
1
Resources
sparklines — pip install sparklines · libregistry