# Termgraph
A command-line tool that draws basic graphs in the terminal, written in Python.
Graph types supported:
- Bar Graphs
- Color charts
- Multi-variable
- Stacked charts
- Histograms
- Horizontal or Vertical
- Emoji!
### Examples
```
termgraph data/ex1.dat
# Reading data from data/ex1.dat
2007: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 183.32
2008: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 231.23
2009: ▇ 16.43
2010: ▇▇▇▇ 50.21
2011: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 508.97
2012: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 212.05
2014: ▏ 1.00
```
An example using emoji as custom tick:
```
termgraph data/ex1.dat --custom-tick "🏃" --width 20 --title "Running Data"
# Running Data
2007: 🏃🏃🏃🏃🏃🏃🏃 183.32
2008: 🏃🏃🏃🏃🏃🏃🏃🏃🏃 231.23
2009: 16.43
2010: 🏃 50.21
2011: 🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃🏃 508.97
2012: 🏃🏃🏃🏃🏃🏃🏃🏃 212.05
2014: 1.00
```
An example using stdin and emoji:
```
echo "Label,3,9,1" | termgraph --custom-tick "😀" --no-label
😀😀😀 3.00
😀😀😀😀😀😀😀😀😀 9.00
😀 1.00
```
Most results can be copied and pasted wherever you like, since they use standard block characters. However the color charts will not show, since they use terminal escape codes for color. A couple images to show color examples:
```
termgraph data/ex4.dat --color {blue,red}
```
<img src="https://user-images.githubusercontent.com/45363/43405623-1a2cc4d4-93cf-11e8-8c96-b7134d8986a2.png" width="655" alt="Multi variable bar chart with colors" />
```
termgraph data/ex7.dat --color {yellow,magenta} --stacked --title "Stacked Data"
```
<img src="https://user-images.githubusercontent.com/45363/43405624-1a4a821c-93cf-11e8-84f3-f45c65b7ca98.png" width="686" alt="Multi variable stacked bar chart with colors" />
Calendar Heatmap, expects first column to be date in yyyy-mm-dd
```
termgraph --calendar --start-dt 2017-07-01 data/cal.dat
```
<img src="https://user-images.githubusercontent.com/45363/43405619-1a15998a-93cf-11e8-8a3f-abfd2f6104a5.png" width="596" alt="Calendar Heatmap" />
### Install
Requires Python 3.9+, install from [PyPI project](https://pypi.org/project/termgraph/)
```
python3 -m pip install termgraph
```
Note: Be sure your PATH includes the pypi install directory, for me it is `~/.local/bin/`
### Usage
#### Command Line Interface
* Create data file with two columns either comma or space separated.
The first column is your labels, the second column is a numeric data
* termgraph [datafile]
* Help: termgraph -h
#### Programmatic API
Termgraph can also be used as a Python library for creating charts programmatically:
```python
from termgraph import Data, Args, BarChart
# Create data
data = Data([[10], [25], [50], [40]], ["Q1", "Q2", "Q3", "Q4"])
# Configure chart options
args = Args(
title="Quarterly Sales",
width=50,
format="{:.0f}",
suffix="K"
)
# Create and display chart
chart = BarChart(data, args)
chart.draw()
```
This produces:
```
# Quarterly Sales
Q1: ▇▇▇▇▇▇▇▇▇▇ 10K
Q2: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 25K
Q3: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50K
Q4: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 40K
```
```
usage: termgraph [-h] [options] [filename]
draw basic graphs on terminal
positional arguments:
filename data file name (comma or space separated). Defaults to stdin.
options:
-h, --help show this help message and exit
--title TITLE Title of graph
--width WIDTH width of graph in characters default:50
--format FORMAT format specifier to use.
--suffix SUFFIX string to add as a suffix to all data points.
--no-labels Do not print the label column
--no-values Do not print the values at end
--space-between Print a new line after every field
--color [COLOR ...] Graph bar color( s )
--vertical Vertical graph
--stacked Stacked bar graph
--histogram Histogram
--bins BINS Bins of Histogram
--different-scale Categories have different scales.
--calendar Calendar Heatmap chart
--start-dt START_DT Start date for Calendar chart
--custom-tick CUSTOM_TICK
Custom tick mark, emoji approved
--delim DELIM Custom delimiter, default , or space
--verbose Verbose output, helpful for debugging
--label-before Display the values before the bars
--no-readable Disable the readable numbers
--percentage Display the number in percentage
--version Display version and exit
```
### Background
I wanted a quick way to visualize data stored in a simple text file. I initially created some scripts in R that generated graphs but this was a two step process of creating the graph and then opening the generated graph.
After seeing [command-line sparklines](https://github.com/holman/spark) I figured I could do the same thing using block characters for bar charts.
### Contribute
All contributions are welcome! For detailed information about the project structure, development workflow, and contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.md).
**Quick Start:**
- 🐛 **Bug reports** and 🚀 **feature requests**: Use [GitHub Issues](https://github.com/mkaz/termgraph/issues)
- 🔧 **Code contributions**: See our [development workflow](CONTRIBUTING.md#development-workflow)
- 📚 **Documentation**: Help improve our guides and examples
**Code Quality:** We use `ruff` for linting and formatting, `mypy` for type checking, and maintain comprehensive test coverage.
Thanks to all the [contributors](https://github.com/mkaz/termgraph/graphs/contributors)!
### License
MIT License, see [LICENSE.txt](LICENSE.txt)
Raw data
{
"_id": null,
"home_page": null,
"name": "termgraph",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "mkaz <marcus@mkaz.com>",
"keywords": "CLI, drawing, graphs, python, shell, terminal, tool, visualization",
"author": null,
"author_email": "mkaz <marcus@mkaz.com>",
"download_url": "https://files.pythonhosted.org/packages/36/18/ce4b484058b16d30e547bbce50500ee2ab28c31f4e26d5faed13503f4c50/termgraph-0.7.2.tar.gz",
"platform": null,
"description": "# Termgraph\n\nA command-line tool that draws basic graphs in the terminal, written in Python.\n\nGraph types supported:\n\n- Bar Graphs\n- Color charts\n- Multi-variable\n- Stacked charts\n- Histograms\n- Horizontal or Vertical\n- Emoji!\n\n\n### Examples\n\n```\ntermgraph data/ex1.dat\n\n# Reading data from data/ex1.dat\n\n2007: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 183.32\n2008: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 231.23\n2009: \u2587 16.43\n2010: \u2587\u2587\u2587\u2587 50.21\n2011: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 508.97\n2012: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 212.05\n2014: \u258f 1.00\n```\n\nAn example using emoji as custom tick:\n\n```\ntermgraph data/ex1.dat --custom-tick \"\ud83c\udfc3\" --width 20 --title \"Running Data\"\n\n# Running Data\n\n2007: \ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3 183.32\n2008: \ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3 231.23\n2009: 16.43\n2010: \ud83c\udfc3 50.21\n2011: \ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3 508.97\n2012: \ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3\ud83c\udfc3 212.05\n2014: 1.00\n\n```\n\n\nAn example using stdin and emoji:\n\n```\necho \"Label,3,9,1\" | termgraph --custom-tick \"\ud83d\ude00\" --no-label\n\n\n\ud83d\ude00\ud83d\ude00\ud83d\ude00 3.00\n\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00\ud83d\ude00 9.00\n\ud83d\ude00 1.00\n\n```\n\nMost results can be copied and pasted wherever you like, since they use standard block characters. However the color charts will not show, since they use terminal escape codes for color. A couple images to show color examples:\n\n```\ntermgraph data/ex4.dat --color {blue,red}\n```\n\n<img src=\"https://user-images.githubusercontent.com/45363/43405623-1a2cc4d4-93cf-11e8-8c96-b7134d8986a2.png\" width=\"655\" alt=\"Multi variable bar chart with colors\" />\n\n```\ntermgraph data/ex7.dat --color {yellow,magenta} --stacked --title \"Stacked Data\"\n```\n\n<img src=\"https://user-images.githubusercontent.com/45363/43405624-1a4a821c-93cf-11e8-84f3-f45c65b7ca98.png\" width=\"686\" alt=\"Multi variable stacked bar chart with colors\" />\n\n\nCalendar Heatmap, expects first column to be date in yyyy-mm-dd\n\n```\ntermgraph --calendar --start-dt 2017-07-01 data/cal.dat\n```\n\n<img src=\"https://user-images.githubusercontent.com/45363/43405619-1a15998a-93cf-11e8-8a3f-abfd2f6104a5.png\" width=\"596\" alt=\"Calendar Heatmap\" />\n\n\n\n### Install\n\nRequires Python 3.9+, install from [PyPI project](https://pypi.org/project/termgraph/)\n\n```\npython3 -m pip install termgraph\n```\n\nNote: Be sure your PATH includes the pypi install directory, for me it is `~/.local/bin/`\n\n### Usage\n\n#### Command Line Interface\n\n* Create data file with two columns either comma or space separated.\n The first column is your labels, the second column is a numeric data\n\n* termgraph [datafile]\n\n* Help: termgraph -h\n\n#### Programmatic API\n\nTermgraph can also be used as a Python library for creating charts programmatically:\n\n```python\nfrom termgraph import Data, Args, BarChart\n\n# Create data\ndata = Data([[10], [25], [50], [40]], [\"Q1\", \"Q2\", \"Q3\", \"Q4\"])\n\n# Configure chart options \nargs = Args(\n title=\"Quarterly Sales\",\n width=50,\n format=\"{:.0f}\",\n suffix=\"K\"\n)\n\n# Create and display chart\nchart = BarChart(data, args)\nchart.draw()\n```\n\nThis produces:\n```\n# Quarterly Sales\n\nQ1: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 10K\nQ2: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 25K \nQ3: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 50K\nQ4: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 40K\n```\n\n```\nusage: termgraph [-h] [options] [filename]\n\ndraw basic graphs on terminal\n\npositional arguments:\n filename data file name (comma or space separated). Defaults to stdin.\n\noptions:\n -h, --help show this help message and exit\n --title TITLE Title of graph\n --width WIDTH width of graph in characters default:50\n --format FORMAT format specifier to use.\n --suffix SUFFIX string to add as a suffix to all data points.\n --no-labels Do not print the label column\n --no-values Do not print the values at end\n --space-between Print a new line after every field\n --color [COLOR ...] Graph bar color( s )\n --vertical Vertical graph\n --stacked Stacked bar graph\n --histogram Histogram\n --bins BINS Bins of Histogram\n --different-scale Categories have different scales.\n --calendar Calendar Heatmap chart\n --start-dt START_DT Start date for Calendar chart\n --custom-tick CUSTOM_TICK\n Custom tick mark, emoji approved\n --delim DELIM Custom delimiter, default , or space\n --verbose Verbose output, helpful for debugging\n --label-before Display the values before the bars\n --no-readable Disable the readable numbers\n --percentage Display the number in percentage\n --version Display version and exit\n```\n\n\n### Background\n\nI wanted a quick way to visualize data stored in a simple text file. I initially created some scripts in R that generated graphs but this was a two step process of creating the graph and then opening the generated graph.\n\nAfter seeing [command-line sparklines](https://github.com/holman/spark) I figured I could do the same thing using block characters for bar charts.\n\n### Contribute\n\nAll contributions are welcome! For detailed information about the project structure, development workflow, and contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.md).\n\n**Quick Start:**\n- \ud83d\udc1b **Bug reports** and \ud83d\ude80 **feature requests**: Use [GitHub Issues](https://github.com/mkaz/termgraph/issues)\n- \ud83d\udd27 **Code contributions**: See our [development workflow](CONTRIBUTING.md#development-workflow) \n- \ud83d\udcda **Documentation**: Help improve our guides and examples\n\n**Code Quality:** We use `ruff` for linting and formatting, `mypy` for type checking, and maintain comprehensive test coverage.\n\nThanks to all the [contributors](https://github.com/mkaz/termgraph/graphs/contributors)!\n\n\n### License\n\nMIT License, see [LICENSE.txt](LICENSE.txt)\n",
"bugtrack_url": null,
"license": null,
"summary": "A command-line tool that draws basic graphs in the terminal.",
"version": "0.7.2",
"project_urls": {
"Changelog": "https://github.com/mkaz/termgraph/releases",
"Homepage": "https://github.com/mkaz/termgraph",
"Issues": "https://github.com/mkaz/termgraph/issues",
"Repository": "https://github.com/mkaz/termgraph"
},
"split_keywords": [
"cli",
" drawing",
" graphs",
" python",
" shell",
" terminal",
" tool",
" visualization"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6537768be97e0f2539e01d4a34f00ffe3b5a6f9d61eb5dbc5c40f44cb8658432",
"md5": "8700e0f263ad121e1ab86e0077e3d417",
"sha256": "6f565cbb2c33767f998ffc571e2bc17556f95b7928d7510c2958e7b2c6fdfa88"
},
"downloads": -1,
"filename": "termgraph-0.7.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8700e0f263ad121e1ab86e0077e3d417",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 18768,
"upload_time": "2025-09-06T13:58:34",
"upload_time_iso_8601": "2025-09-06T13:58:34.945363Z",
"url": "https://files.pythonhosted.org/packages/65/37/768be97e0f2539e01d4a34f00ffe3b5a6f9d61eb5dbc5c40f44cb8658432/termgraph-0.7.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3618ce4b484058b16d30e547bbce50500ee2ab28c31f4e26d5faed13503f4c50",
"md5": "a7379efa205dde1bd28de66701c116cf",
"sha256": "8bda932a1e3e121e9a3b5f3f267c85ca7c344fdbc60883e340509bc4af2bc4ee"
},
"downloads": -1,
"filename": "termgraph-0.7.2.tar.gz",
"has_sig": false,
"md5_digest": "a7379efa205dde1bd28de66701c116cf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 301960,
"upload_time": "2025-09-06T13:58:36",
"upload_time_iso_8601": "2025-09-06T13:58:36.395009Z",
"url": "https://files.pythonhosted.org/packages/36/18/ce4b484058b16d30e547bbce50500ee2ab28c31f4e26d5faed13503f4c50/termgraph-0.7.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-06 13:58:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mkaz",
"github_project": "termgraph",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "termgraph"
}