Termgraph is a Python command-line tool that draws basic graphs directly in the terminal. It reads data from CSV files and renders horizontal bar charts, stacked charts, and multi-variable comparisons using Unicode block characters. This is useful when you need quick data visualization during SSH sessions, inside shell scripts, or as part of CI/CD pipeline output – no GUI or browser required.
This guide covers installing termgraph on Linux, creating data files, and generating different chart types with customization options for colors, labels, titles, and suffixes. All commands were tested on Ubuntu 24.04 with termgraph 0.7.5.
Prerequisites
- A Linux system (Ubuntu, Debian, RHEL, Rocky Linux, Fedora, etc.)
- Python 3 installed (included by default on most modern distributions)
- pip3 (Python package manager)
- A regular user account with sudo access
Step 1: Install Termgraph
Install pip if it is not already present on your system. On Debian/Ubuntu:
sudo apt install python3-pip -y
On RHEL, Rocky Linux, or AlmaLinux:
sudo dnf install python3-pip -y
Install termgraph using pip:
pip3 install termgraph
On Ubuntu 24.04 and newer Debian-based systems, pip installs packages to ~/.local/bin by default. If the termgraph command is not found after installation, add that directory to your PATH:
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Verify the installation by checking the version:
termgraph --version
The output confirms termgraph is installed and accessible:
termgraph 0.7.5
Step 2: Draw a Basic Bar Graph in the Terminal
Termgraph reads data from simple CSV files where the first column is the label and the second column is the numeric value. Create a sample data file with programming language popularity scores:
echo "Python,85" > languages.csv
echo "JavaScript,72" >> languages.csv
echo "Go,63" >> languages.csv
echo "Rust,58" >> languages.csv
echo "TypeScript,50" >> languages.csv
Run termgraph against the data file:
termgraph languages.csv
Termgraph renders a horizontal bar chart with labels on the left and values on the right. The bar length is proportional to each value:
Python : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85.00
JavaScript: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 72.00
Go : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 63.00
Rust : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 58.00
TypeScript: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50.00
Step 3: Add Titles, Suffixes, and Custom Width
Termgraph supports several flags to customize the chart appearance. Use --title to add a heading above the chart, --suffix to append a unit to each value, and --width to control the maximum bar length in characters.
termgraph languages.csv --title "Language Popularity" --suffix "%" --width 40
The chart now displays a title at the top and a percentage sign after each value:
# Language Popularity
Python : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85.00%
JavaScript: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 72.00%
Go : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 63.00%
Rust : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 58.00%
TypeScript: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 50.00%
The --width flag accepts an integer that sets the number of characters for the longest bar. Smaller values produce more compact charts suitable for narrow terminal windows.
Step 4: Create Multi-Variable Charts
Termgraph can compare multiple data series side by side. Add extra comma-separated columns to the CSV file – each column after the label becomes a separate bar. Create a file comparing Q1 and Q2 sales figures:
echo "North,120,145" > sales.csv
echo "South,95,110" >> sales.csv
echo "East,80,92" >> sales.csv
echo "West,105,130" >> sales.csv
Run termgraph on the multi-column data:
termgraph sales.csv
Each label gets two bars – one for each data column. This makes it easy to compare values across categories:
North: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 120.00
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 145.00
South: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 95.00
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 110.00
East : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 80.00
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 92.00
West : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 105.00
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 130.00
Step 5: Generate Stacked Charts
For multi-column data, you can stack the values into a single bar per label instead of showing them side by side. Use the --stacked flag:
termgraph sales.csv --stacked
Stacked bars combine both values into one bar, showing the total while preserving the breakdown. Each segment uses a different character:
North: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏ 265.00
South: ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏ 205.00
East : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏ 172.00
West : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▏ 235.00
Stacked charts are useful when you want to show both individual contributions and the combined total at a glance.
Step 6: Add Colors to Termgraph Charts
Use the --color flag to set bar colors. Available colors are: red, blue, green, magenta, yellow, black, and cyan. For single-variable data, specify one color:
termgraph languages.csv --color green
For multi-variable charts, provide one color per data column. The colors are assigned in order to each column:
termgraph sales.csv --color red blue
This renders the first column bars in red and the second column bars in blue, making it easy to distinguish between the two data series in your terminal.
Step 7: Control Labels and Values Display
Termgraph provides flags to control what text appears alongside the bars. The --label-before flag moves the label to appear before the bar instead of using the default alignment:
termgraph languages.csv --label-before
To hide labels entirely, use --no-labels. This is useful when embedding chart output in scripts where you only need the visual bars:
termgraph languages.csv --no-labels
To hide the numeric values at the end of each bar, use --no-values:
termgraph languages.csv --no-values
You can combine these flags. For example, to show only the bars with labels but no numbers:
termgraph languages.csv --no-values --color cyan
The chart displays colored bars with labels but strips the numeric values from the output. This produces a cleaner visual when the exact numbers are not important.
Termgraph Command Reference
The table below lists all available termgraph flags and what they control:
| Flag | Description |
|---|---|
--title TITLE | Add a title above the chart |
--width WIDTH | Set maximum bar width in characters (default 50) |
--suffix SUFFIX | Append text after each value (e.g. %, units) |
--format FORMAT | Python format string for values (e.g. {:.0f} for no decimals) |
--color COLOR | Set bar colors – red, blue, green, magenta, yellow, black, cyan |
--stacked | Stack multi-column data into single bars |
--vertical | Draw vertical bars instead of horizontal |
--histogram | Treat input as raw values and draw a histogram |
--bins BINS | Number of bins for histogram mode |
--no-labels | Hide row labels |
--no-values | Hide numeric values at the end of bars |
--label-before | Place labels before bars |
--space-between | Add blank line between each row |
--different-scale | Scale each data series independently |
--calendar | Display data in a calendar heatmap format |
--custom-tick CHAR | Use a custom character instead of the default block |
--delim DELIM | Set custom delimiter (default is comma) |
--no-readable | Disable human-readable number formatting |
--percentage | Show values as percentages of the total |
Conclusion
Termgraph turns CSV data into readable bar charts directly in the terminal with no external dependencies beyond Python 3. It fits well into shell scripts, cron job reports, and quick data analysis during SSH sessions. For more details and advanced usage, check the termgraph GitHub repository.