Termgraph - Simple charts in your Linux Terminal using Python & CLI
Today i was just thinking how do we create some cool charts in our terminal without any big GUI Dashboard kind of tools like Splunk,Power BI,Grafana etc.
Thanks to a wonderful python module called termgraph
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!
Installation
pip install termgraph
Note : you need a python version of 3.6 + to work however i was looking if there is any tweak available for 2.7 as the default python person i had was 2.7
Sample data
# Example Data Set with 2 Categories @ Oranges,Pineapples 2018,200.45,70.5 2017,110.45,300.46 2016,77.89,120.45 2015,66.2,345.22 2014,760.00,30.24 2013,450.56,472
Sample Data and Testing was done using below link as a reference.
Ended up with the below error
As stated earlier termgraph is applicable for Python 3.6 and above but still there are folks who always make impossible to possible.
Fix is just to do below. Credits to BoltzmannBrain.
open the vi editor and add the entry as specified by BoltzmannBrain
Now run through command line utility of termgraph.
termgraph test2.dat --color {red,green}
Note : We get a great display only in GUI Terminal. I tried the same in Putty terminal
In case if you want to try it out in Putty just use operators (+,-,*) etc using custom ticks parameter.
termgraph -h (help) can be useful to draw various graphs at command line instead of using great GUI tools.
Hope this was useful.