Package: itermplot
An awesomeiTerm2backend for Matplotlib,
so you can plot directly in your terminal.The above is achieved with zero modifications to your Python script. For
example, the above plots are generated with the following code:import numpy as np
import matplotlib.pyplot as plt
import networkx as nx

plt.rcParams["font.size"] = 10

plt.figure(figsize=(8,3))

ax = plt.subplot(121)
x = np.arange(0,10,0.001)
ax.plot(x, np.sin(np.sinc(x)), 'r', lw=2)
ax.set_title('Nice wiggle')

ax = plt.subplot(122)
plt.tick_params(axis='both', left='off', top='off', right='off', bottom='off', labelleft='off', labeltop='off', labelright='off', labelbottom='off')
G = nx.random_geometric_graph(200, 0.125)
pos=nx.spring_layout(G)
nx.draw_networkx_edges(G, pos, alpha=0.2)
nx.draw_networkx_nodes(G, pos, node_color='r', node_size=12)
ax.set_title('Random graph')

plt.show()Note: you need to runplt.show()to display the figure.Reverse videoIf you use a dark background in your terminal, you can enable “reverse
video” mode by adding this to your.profile:export ITERMPLOT=rvTMUX supportitermplot tries to auto-detect TMUX and behave in a sane way. Vertical
split panes do not work well due to a limitation with iTerm2. Luckily,
horizontals do though.Animation supportitermplot supports animation created by matplotlib animation module.You’ll need to install ImageMagick and have it on the path to use the
animation support. The simpliest way to see if ImageMagick is installed
and valid is to run:$ convert -version
Version: ImageMagick 7.0.4-4 Q16 x86_64 2017-01-14 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules
Delegates (built-in): bzlib freetype jng jpeg ltdl lzma png tiff xml zlibTo enable animation support, you need to specifying the desired number
of frames in the output animation. For example, specify it before your
script with:$ ITERMPLOT_FRAMES=30 python script.pyYou can also save the resulting gif file by usingITERMPLOT_OUTFILEenvironment variable:$ ITERMPLOT_FRAMES=30 ITERMPLOT_OUTFILE=out.gif python script.pyCurrently animation does not support reverse video with ITERMPLOT=rv.Configure linesYou can configure the number of lines used with theITERMPLOT_LINESenvironment variable. For example:ITERMPLOT_LINES=5 python3 simple.pyPython 2 and Python 3 supportNow supports Python 2, even if this makes me want to cry 😭InstallationUsing pipInstall usingpipusing the command:pip3 install itermplotitermplot is enabled by settingMPLBACKENDin your environment. If
you usebash, then this can be accomplished using the command:export MPLBACKEND="module://itermplot"Note: you can add theexportline above to your.profilefile so
that itermplot is always enabled in your terminal.TestingTo test your installation you can do the following in your iTerm2
console:$ echo $MPLBACKEND
module://itermplot
$ python3
Python 3.5.2 (default, Oct 24 2016, 09:14:06)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x1041f2e48>]
>>> plt.show()You should see a plot!UninstallYou can disable this backend by unsetting theMPLBACKENDenvironment
variable.$ unset MPLBACKEND
$ echo $MPLBACKEND

$ python3
Python 3.5.2 (default, Oct 24 2016, 09:14:06)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x1106bdcc0>]
>>> plt.show()To remove the package completely, run:pip3 uninstall itermplotBugsThis backend is very alpha, so if you have a problem please raise an
Issue on GitHub and I will try to fix it.I also accept (and appreciate!) good patches / pull request. Thanks togarrywu,brenshanny,hbredin,zevlgfor their patches so far.Other cool thingsI encourage you to check-out some of myother little
projects. Lots more coming as I
slowly release them…