{"id":2980,"date":"2026-03-22T03:43:57","date_gmt":"2018-07-29T21:13:55","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=2980"},"modified":"2026-03-22T03:43:58","modified_gmt":"2026-03-22T00:43:58","slug":"draw-graphs-terminal-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/draw-graphs-terminal-linux\/","title":{"rendered":"Draw Graphs in Linux Terminal with Termgraph"},"content":{"rendered":"\n<p><a href=\"https:\/\/github.com\/mkaz\/termgraph\" target=\"_blank\" rel=\"noreferrer noopener\">Termgraph<\/a> 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 &#8211; no GUI or browser required.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Linux system (Ubuntu, Debian, RHEL, Rocky Linux, Fedora, etc.)<\/li>\n\n<li>Python 3 installed (included by default on most modern distributions)<\/li>\n\n<li>pip3 (Python package manager)<\/li>\n\n<li>A regular user account with sudo access<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install Termgraph<\/h2>\n\n\n\n<p>Install pip if it is not already present on your system. On Debian\/Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install python3-pip -y<\/code><\/pre>\n\n\n\n<p>On RHEL, Rocky Linux, or AlmaLinux:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install python3-pip -y<\/code><\/pre>\n\n\n\n<p>Install termgraph using pip:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip3 install termgraph<\/code><\/pre>\n\n\n\n<p>On Ubuntu 24.04 and newer Debian-based systems, pip installs packages to <code>~\/.local\/bin<\/code> by default. If the <code>termgraph<\/code> command is not found after installation, add that directory to your PATH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'export PATH=\"$HOME\/.local\/bin:$PATH\"' >> ~\/.bashrc\nsource ~\/.bashrc<\/code><\/pre>\n\n\n\n<p>Verify the installation by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph --version<\/code><\/pre>\n\n\n\n<p>The output confirms termgraph is installed and accessible:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph 0.7.5<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Draw a Basic Bar Graph in the Terminal<\/h2>\n\n\n\n<p>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:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"Python,85\" > languages.csv\necho \"JavaScript,72\" >> languages.csv\necho \"Go,63\" >> languages.csv\necho \"Rust,58\" >> languages.csv\necho \"TypeScript,50\" >> languages.csv<\/code><\/pre>\n\n\n\n<p>Run termgraph against the data file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv<\/code><\/pre>\n\n\n\n<p>Termgraph renders a horizontal bar chart with labels on the left and values on the right. The bar length is proportional to each value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Python    : \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 85.00\nJavaScript: \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 72.00\nGo        : \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 63.00\nRust      : \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 58.00\nTypeScript: \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 50.00<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Add Titles, Suffixes, and Custom Width<\/h2>\n\n\n\n<p>Termgraph supports several flags to customize the chart appearance. Use <code>--title<\/code> to add a heading above the chart, <code>--suffix<\/code> to append a unit to each value, and <code>--width<\/code> to control the maximum bar length in characters.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --title \"Language Popularity\" --suffix \"%\" --width 40<\/code><\/pre>\n\n\n\n<p>The chart now displays a title at the top and a percentage sign after each value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Language Popularity\n\nPython    : \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 85.00%\nJavaScript: \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 72.00%\nGo        : \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 63.00%\nRust      : \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 58.00%\nTypeScript: \u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587\u2587 50.00%<\/code><\/pre>\n\n\n\n<p>The <code>--width<\/code> 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Create Multi-Variable Charts<\/h2>\n\n\n\n<p>Termgraph can compare multiple data series side by side. Add extra comma-separated columns to the CSV file &#8211; each column after the label becomes a separate bar. Create a file comparing Q1 and Q2 sales figures:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"North,120,145\" > sales.csv\necho \"South,95,110\" >> sales.csv\necho \"East,80,92\" >> sales.csv\necho \"West,105,130\" >> sales.csv<\/code><\/pre>\n\n\n\n<p>Run termgraph on the multi-column data:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph sales.csv<\/code><\/pre>\n\n\n\n<p>Each label gets two bars &#8211; one for each data column. This makes it easy to compare values across categories:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>North: \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 120.00\n       \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 145.00\nSouth: \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 95.00\n       \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 110.00\nEast : \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 80.00\n       \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 92.00\nWest : \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 105.00\n       \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 130.00<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Generate Stacked Charts<\/h2>\n\n\n\n<p>For multi-column data, you can stack the values into a single bar per label instead of showing them side by side. Use the <code>--stacked<\/code> flag:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph sales.csv --stacked<\/code><\/pre>\n\n\n\n<p>Stacked bars combine both values into one bar, showing the total while preserving the breakdown. Each segment uses a different character:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>North: \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\u258f\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\u258f 265.00\nSouth: \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\u258f\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\u258f 205.00\nEast : \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\u258f\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\u258f 172.00\nWest : \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\u258f\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\u258f 235.00<\/code><\/pre>\n\n\n\n<p>Stacked charts are useful when you want to show both individual contributions and the combined total at a glance.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Add Colors to Termgraph Charts<\/h2>\n\n\n\n<p>Use the <code>--color<\/code> flag to set bar colors. Available colors are: red, blue, green, magenta, yellow, black, and cyan. For single-variable data, specify one color:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --color green<\/code><\/pre>\n\n\n\n<p>For multi-variable charts, provide one color per data column. The colors are assigned in order to each column:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph sales.csv --color red blue<\/code><\/pre>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Control Labels and Values Display<\/h2>\n\n\n\n<p>Termgraph provides flags to control what text appears alongside the bars. The <code>--label-before<\/code> flag moves the label to appear before the bar instead of using the default alignment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --label-before<\/code><\/pre>\n\n\n\n<p>To hide labels entirely, use <code>--no-labels<\/code>. This is useful when embedding chart output in scripts where you only need the visual bars:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --no-labels<\/code><\/pre>\n\n\n\n<p>To hide the numeric values at the end of each bar, use <code>--no-values<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --no-values<\/code><\/pre>\n\n\n\n<p>You can combine these flags. For example, to show only the bars with labels but no numbers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>termgraph languages.csv --no-values --color cyan<\/code><\/pre>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Termgraph Command Reference<\/h2>\n\n\n\n<p>The table below lists all available termgraph flags and what they control:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Flag<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>--title TITLE<\/code><\/td><td>Add a title above the chart<\/td><\/tr><tr><td><code>--width WIDTH<\/code><\/td><td>Set maximum bar width in characters (default 50)<\/td><\/tr><tr><td><code>--suffix SUFFIX<\/code><\/td><td>Append text after each value (e.g. %, units)<\/td><\/tr><tr><td><code>--format FORMAT<\/code><\/td><td>Python format string for values (e.g. {:.0f} for no decimals)<\/td><\/tr><tr><td><code>--color COLOR<\/code><\/td><td>Set bar colors &#8211; red, blue, green, magenta, yellow, black, cyan<\/td><\/tr><tr><td><code>--stacked<\/code><\/td><td>Stack multi-column data into single bars<\/td><\/tr><tr><td><code>--vertical<\/code><\/td><td>Draw vertical bars instead of horizontal<\/td><\/tr><tr><td><code>--histogram<\/code><\/td><td>Treat input as raw values and draw a histogram<\/td><\/tr><tr><td><code>--bins BINS<\/code><\/td><td>Number of bins for histogram mode<\/td><\/tr><tr><td><code>--no-labels<\/code><\/td><td>Hide row labels<\/td><\/tr><tr><td><code>--no-values<\/code><\/td><td>Hide numeric values at the end of bars<\/td><\/tr><tr><td><code>--label-before<\/code><\/td><td>Place labels before bars<\/td><\/tr><tr><td><code>--space-between<\/code><\/td><td>Add blank line between each row<\/td><\/tr><tr><td><code>--different-scale<\/code><\/td><td>Scale each data series independently<\/td><\/tr><tr><td><code>--calendar<\/code><\/td><td>Display data in a calendar heatmap format<\/td><\/tr><tr><td><code>--custom-tick CHAR<\/code><\/td><td>Use a custom character instead of the default block<\/td><\/tr><tr><td><code>--delim DELIM<\/code><\/td><td>Set custom delimiter (default is comma)<\/td><\/tr><tr><td><code>--no-readable<\/code><\/td><td>Disable human-readable number formatting<\/td><\/tr><tr><td><code>--percentage<\/code><\/td><td>Show values as percentages of the total<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>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 <a href=\"https:\/\/github.com\/mkaz\/termgraph\" target=\"_blank\" rel=\"noreferrer noopener\">termgraph GitHub repository<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8230; <a title=\"Draw Graphs in Linux Terminal with Termgraph\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/draw-graphs-terminal-linux\/\" aria-label=\"Read more about Draw Graphs in Linux Terminal with Termgraph\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":3003,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50,299,68,9275],"tags":[499],"class_list":["post-2980","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-tutorials","category-how-to","category-programming","category-terminal","tag-termgraph"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2980","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=2980"}],"version-history":[{"count":3,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2980\/revisions"}],"predecessor-version":[{"id":163460,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2980\/revisions\/163460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/3003"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=2980"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=2980"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=2980"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}