mplterm: terminal backend(s) for Matplotlib
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 onicat
, 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 thatmplterm
will automatically and silently set (once) thenumColorRegisters
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 ofiterm2
,kitty
, orsixel
.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 toitermplot
).
Other terminal backends for Matplotlib
iterm2
:kitty
:sixel
:- matplotlib-sixel (not on PyPI; uses
ImageMagick
's sixel support). - sixelplot (wraps PySixel; not a Matplotlib backend but rather provides
sixelplot.show()
which displays the current figure).
- matplotlib-sixel (not on PyPI; uses