![]() |
When working from the command line, having an immediate view of your data can make a big difference. In this context, termcharts was born, a Python library designed to create graphs directly in the terminal in a simple, fast and intuitive way.
termcharts can be seen as a simplification of termgraph (we talked about it in the article 📊 View charts in the terminal with termgraph using Python): it maintains the philosophy of text display, but drastically reduces the complexity of the API, making it quick to understand and use, even for those who have never worked with graphs in the terminal.
Why use termcharts
The main advantages of the library are:
- 📦 No complex dependencies
- ⚡ Immediate setup
- 🧠 Minimal and intuitive API
- 🖥️ Readable output directly in the terminal
- 🔄 Ideal for scripts, CLI tools, and quick reports
No graphics configuration required: everything is rendered as ASCII text.
Installation
pip install termcharts
After installation, the library is ready for use.
Library Import
import termcharts
A single import is sufficient: all the main functions are exposed directly by the module.
🍰 Pie Chart
chart_pie = termcharts.pie(
{'Bugs': 30, 'Tasks': 60, 'Other': 10},
title='Activities'
)
print(chart_pie)
Step-by-Step Explanation
-
Data
Provided as a dictionarylabel → value
Each key represents a category. -
pie() Function
Creates a text pie chart.
Automatically calculates percentages. -
titleparameter>
Adds a title to the chart for easier readability. -
print(chart_pie)
The chart is only rendered when printed.
This chart type is ideal for showing the percentage distribution of data.
🍩 Doughnut Chart
chart_doughnut = termcharts.doughnut(
{'High impact': 10, 'Medium impact': 20, 'Low impact': 30},
title='Priority tasks'
)
print(chart_doughnut)
Difference from the pie chart
The doughnut chart is a variant of the pie chart:
- Same input logic
- More compact representation
- More readable when there are many categories
Here too, simplicity is the strong point: just change the function.
📊 Bar Charts
Horizontal Bar Chart
chart1 = termcharts.bar(
{'Task1': 54, 'Task2': 20, 'Task3': 30, 'Task4': 15, 'Task5': 5},
title='Status'
)
print(chart1)
Explanation
- The dictionary keys are the labels
- The values determine the length of the bars
- The horizontal layout is the default
Vertical bar chart
chart2 = termcharts.bar(
{'Task1': 54, 'Task2': 20, 'Task3': 30, 'Task4': 15, 'Task5': 5},
title='Status (vertical)',
mode='v'
)
print(chart2)
This is where the parameter comes in:
mode='v'→ forces vertical display
This is especially useful when you want to compare values in a more "graphical" way.
Bar chart from list
chart3 = termcharts.bar(
[54, 20, 30, 15, 5],
title='Status (list)'
)
print(chart3)
In this case:
- The data is passed as a list
- The labels are automatically generated
- It's perfect for simple or temporary datasets
🎯 All examples in a single script
To get a complete overview of the potential of termcharts, you can collect all the examples seen so far in a Single Python script.
This approach is particularly useful for:
- quickly testing the library
- comparing different chart types
- generating complete output to display in documentation or articles
- adding a screenshot of the result in the terminal
Here is the complete script, as it can be run directly:
import termcharts
'''
=== PIE CHART ===
'''
chart_pie = termcharts.pie(
{'Bugs': 30, 'Tasks': 60, 'Other': 10},
title='Activities'
)
print(chart_pie)
'''
=== DOUGHNUT CHART ===
'''
chart_doughnut = termcharts.doughnut(
{'High impact': 10, 'Medium impact': 20, 'Low impact': 30},
title='Priority tasks'
)
print(chart_doughnut)
'''
=== BAR CHARTS ===
'''
chart1 = termcharts.bar(
{'Task1': 54, 'Task2': 20, 'Task3': 30, 'Task4': 15, 'Task5': 5},
title='Status'
)
chart2 = termcharts.bar(
{'Task1': 54, 'Task2': 20, 'Task3': 30, 'Task4': 15, 'Task5': 5},
title='Status (vertical)',
mode='v' # vertical
)
chart3 = termcharts.bar(
[54, 20, 30, 15, 5],
title='Status (list)' # from list
)
print(chart1)
print(chart2)
print(chart3)
How to use the script
- Save the code to a file, for example
termcharts_demo.py -
Run it from the terminal:
python termcharts_demo.py -
The output will show, in sequence:
- a pie chart
- a doughnut chart
- a horizontal bar chart
- a vertical bar chart
- a bar chart generated from a list
At this point, you can take a screenshot terminal output and insert it into the article to visually display the final result.
Termcharts Philosophy
The real strength of termcharts lies in its philosophy:
“Display data in the simplest way possible, without forcing the developer to learn a complex API.”
Compared to termgraph, termcharts:
- ✅ Reduces the number of parameters
- ✅ Hidesnde internal complexity
- ✅ Offers out-of-the-box functions
- ✖️ The price you pay for this simplicity is the lack of customization (e.g., you can't show labels for bar charts)
When to use termcharts
- Monitoring scripts
- CLI tools
- Fast dataset debugging
- Text-based reports
- GUI-free environments
Conclusion
termcharts is a small but extremely effective library: an intelligent simplification of termgraph that allows you to create graphs in the terminal in seconds.
If you're looking for a quick way to visualize data without leaving the terminal, termcharts is an excellent choice.
Follow me #techelopment
Official site: www.techelopment.it
facebook: Techelopment
instagram: @techelopment
X: techelopment
Bluesky: @techelopment
telegram: @techelopment_channel
whatsapp: Techelopment
youtube: @techelopment

