/mplterm

Terminal backend(s) for Matplotlib

Primary LanguagePythonzlib LicenseZlib

mplterm: terminal backend(s) for Matplotlib

GitHub

mplterm supports outputting Matplotlib figures directly to some terminals. Currently, mplterm supports (to various degrees) the iterm2, kitty, and sixel protocols, but other protocols may be implemented in the future.

This package's implementation is inspired by itermplot and other terminal integrations for Matplotlib, as listed below. (Unlike itermplot, mplterm does not support tmux or Matplotlib animations.)

Install with pip, as any Python package. Use by setting your Matplotlib backend (e.g. via the MPLBACKEND environment variable) to module://mplterm. The protocol to be used is normally auto-detected.

Protocols

  • The iterm2 protocol is supported by the iterm2 and wsltty terminals. For testing purposes, I actually only have access to the latter, and support is known to be currently incomplete and buggy. Also note that plain mintty explicitly does not work.
  • The kitty protocol is only supported by the kitty terminal. The implementation is currently based on icat, and thus requires ImageMagick.
  • The sixel protocol requires a sixel-capable terminal (xterm and mlterm are known to work) and ImageMagick≄7.0.1. Note that mplterm will automatically and silently set (once) the numColorRegisters resource to its maximum allowed value.

Configuration

Configuration is done via the MPLTERM environment variable, which should be set to a colon-separate list of codes:

  • proto=...: Force the protocol to one of iterm2, kitty, or sixel.
  • tr: Make the figure and axes background transparent, if the protocol supports transparency (the sixel protocol, implemented via ImageMagick, doesn't support it).
  • rv: Reverse-video the colors (similarly to itermplot).

Other terminal backends for Matplotlib