Matplotlib backend for direct plotting in the terminal.
Project description
kitcat
This project introduces a new kitcat backend for Matplotlib that allows plots to be displayed directly in the terminal. It utilizes the "agg" backend for rendering plots before sending them to the terminal.
- Direct Matplotlib plotting in terminal emulators that support Kitty or iTerm2 graphics protocols.
- Works seamlessly over SSH and inside tmux.
Installation
pip install kitcat
Usage
Select kitcat backend after importing matplotlib:
import matplotlib
matplotlib.use("kitcat")
or if pyplot is already imported, switch_backend() can be used to select kitcat backend:
import matplotlib.pyplot as plt
plt.switch_backend("module://kitcat")
Terminal Emulator Support
Kitty and Ghostty are the recommended terminals. They implement modern protocol which let kitcat embed the image into the terminal's text buffer rather than overlaying it on the screen. This means plots scroll with the buffer, clip correctly at pane boundaries, and behave properly inside tmux — see tmux notes. Other supported terminals still work, but the image is drawn at a fixed screen position and won't track the buffer as cleanly.
| Terminal Emulator | Supported | Notes |
|---|---|---|
| Kitty | ✅✨ | |
| Ghostty | ✅✨ | |
| iTerm2 | ✅ | |
| VSCode | ✅ | Requires terminal.integrated.enableImages in settings |
| WezTerm | ✅ | |
| tmux | ✅ | See tmux notes |
| Warp | ✅ | |
| wayst | ✅ | |
| st | ✅ | Requires st-kitty-graphics patch |
| Zellij | ❌ | |
| Alacritty | ❌ | |
| Terminal.app (macOS) | ❌ |
tmux notes
On Kitty and Ghostty, kitcat uses Unicode placeholders so the image becomes part of tmux's text buffer — it scrolls with the buffer, clips at the pane boundary, and disappears when the pane is hidden. On other terminals, the image is drawn directly by the outer emulator and stays at a fixed screen position (so it can persist when switching panes — this is a tmux/terminal limitation, not a kitcat one).
Either way, set -g allow-passthrough on is required in your tmux config.
Acknowledgements
I discovered matplotlib-backend-kitty repository, which provides similar functionality in Kitty. I aimed to create a simpler solution that works across any terminal supporting the protocol.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kitcat-2.0.2.tar.gz.
File metadata
- Download URL: kitcat-2.0.2.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e77abff140c12230086c4f120f98a48a09f2cb33e63b3d06818a134767c4728
|
|
| MD5 |
ad07c232a8ac3c027c4bc4a16d843d73
|
|
| BLAKE2b-256 |
a1e6e470293651d654b978fb1fff083808dea9f96ead77c2fd4f3c9702408dcd
|
File details
Details for the file kitcat-2.0.2-py3-none-any.whl.
File metadata
- Download URL: kitcat-2.0.2-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.5.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
764733af7253d8b507a6fed0398ae44dcdf3af2db4a818ee321e4fbdcdc38128
|
|
| MD5 |
50560ae3435b2e5f0e3985cf79ccf32c
|
|
| BLAKE2b-256 |
db06e4b11e33168b7229742e76c70f4fa827e4110c7914293c498fdba1d5ab1c
|