Draw simple plots and charts in the terminal using ASCII symbols
Project description
Terminal Plot
Draw beautiful plots and charts in your terminal using ASCII and Unicode symbols
Features
- Bar Charts - Horizontal and vertical bar charts for categorical data
- Line Charts - Single and multi-series line plots with automatic scaling
- Scatter Plots - Visualize correlations and relationships
- Histograms - Show data distributions with customizable bins
- Dual Modes - Beautiful Unicode symbols or ASCII for compatibility
- Color Support - Optional ANSI colors for better visualization
- Zero Dependencies - Pure Python, works anywhere
- Lightweight - Fast and minimal resource usage
Installation
From source
git clone https://github.com/mosioc/term-plot.git
cd term-plot
pip install -e .
Quick Start
Bar Chart
from term_plot import BarChart
# Simple horizontal bar chart
data = [23, 45, 12, 67, 34, 89, 56]
labels = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
chart = BarChart(data, labels=labels, title="Daily Sales", width=50)
print(chart.horizontal())
# Vertical bar chart
chart = BarChart(data, labels=labels, title="Daily Sales", height=15)
print(chart.vertical())
Line Chart
from term_plot import LineChart
# Single series
data = [1, 3, 7, 4, 8, 6, 9, 12, 10]
chart = LineChart(data, title="Temperature Over Time", width=60, height=15)
print(chart.plot())
# Multiple series
data = {
"Product A": [5, 7, 9, 12, 15, 18, 20],
"Product B": [3, 5, 8, 10, 12, 15, 17]
}
chart = LineChart(data, title="Sales Comparison", width=70, height=20)
print(chart.plot())
Scatter Plot
from term_plot import ScatterPlot
x_data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y_data = [2, 4, 3, 5, 7, 6, 8, 9, 8]
chart = ScatterPlot(x_data, y_data, title="Correlation Plot", width=50, height=15)
print(chart.plot())
Histogram
from term_plot import Histogram
import random
# Generate sample data
data = [random.gauss(50, 15) for _ in range(1000)]
chart = Histogram(data, bins=15, title="Test Score Distribution", width=60, height=15)
print(chart.plot())
Customization Options
ASCII vs Unicode
# Unicode mode (default) - prettier but requires Unicode support
chart = BarChart(data, labels=labels, use_unicode=True)
# ASCII mode - works everywhere
chart = BarChart(data, labels=labels, use_unicode=False)
Colors
# With colors (default)
chart = BarChart(data, labels=labels, color=True)
# Without colors
chart = BarChart(data, labels=labels, color=False)
Size Control
# Custom width and height
chart = LineChart(data, width=80, height=25)
Examples
Check out the examples/ directory for more:
bar_chart_example.py- Various bar chart stylesline_chart_example.py- Line chart examples including sine wavesdemo_all.py- Comprehensive demo of all chart types
Run examples:
cd examples
python demo_all.py
Testing
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=term_plot
Requirements
- Python 3.8 or higher
- No external dependencies!
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Inspired by various terminal plotting libraries
- Unicode block elements from the Unicode standard
- ANSI color codes for terminal colors
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
term_plot_mc-0.1.2.tar.gz
(12.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file term_plot_mc-0.1.2.tar.gz.
File metadata
- Download URL: term_plot_mc-0.1.2.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b915ae1926fff4092878e4c57dd21f3dc0b10db8aeb382c02e7e0e7b3e39b14b
|
|
| MD5 |
8836a92e2aae42eece1f95f52ee4b862
|
|
| BLAKE2b-256 |
6533897998b9a16eb7df75d2a47a9620f1e032a0dc9dcd2c65ac5c22978d859e
|
File details
Details for the file term_plot_mc-0.1.2-py3-none-any.whl.
File metadata
- Download URL: term_plot_mc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba99988cd8394c8f467e4f5fcc5656c7c319e0a997dc08ab89cb4e8866ea598d
|
|
| MD5 |
443f2f78c51643853ace2701c440096c
|
|
| BLAKE2b-256 |
9416f16c822e1132a5874f99cbd3cc07287681246d23af00ef4c3f19c6ad2eb7
|