Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kitcat-2.0.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kitcat-2.0.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file kitcat-2.0.0.tar.gz.

File metadata

  • Download URL: kitcat-2.0.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.11

File hashes

Hashes for kitcat-2.0.0.tar.gz
Algorithm Hash digest
SHA256 64c90ad5663015f9ce34ee9052245ce312cb83f6a6756bc6a084fc39d5c9d588
MD5 6f02104503433243849dea2816637056
BLAKE2b-256 58fcb84a86caaecf987797ed3b64d90a36317a6b427b72e84a0002348b2e7b65

See more details on using hashes here.

File details

Details for the file kitcat-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: kitcat-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.5.11

File hashes

Hashes for kitcat-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d58cc8ab532b0005889ffe834eaec22d41f9363f73c0b30643e20643db7e95eb
MD5 75a70dae117b6f40af91e60fa8af81ba
BLAKE2b-256 97019373d3f14e22b8bdbedd75fea1048d0f31c2ecaa0ee9825f91aae82ac8e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page