Skip to content
Plotting on the command line
Python Makefile
Branch: master
Clone or download
Latest commit 050695a Sep 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci rename to termplotlib Sep 26, 2019
.github/workflows rename to termplotlib Sep 26, 2019
termplotlib Move unicode check to helpers Sep 29, 2019
test rename to termplotlib Sep 26, 2019
.flake8 add flake8 config Jun 9, 2018
.gitignore scaffold for subplot support Jun 1, 2018
LICENSE.txt add license Mar 8, 2019
Makefile rename to termplotlib Sep 26, 2019
README.md remove warning in readme Sep 26, 2019
codecov.yml codecov: don't comment Aug 9, 2018
setup.py
test_requirements.txt Move unicode check to helpers Sep 29, 2019

README.md

termplotlib

CircleCI codecov Code style: black PyPi Version GitHub stars PyPi downloads

termplotlib is a Python library for all your terminal plotting needs. It aims to work like matplotlib.

Line plots

For line plots, termplotlib relies on gnuplot. With that installed, the code

import termplotlib as tpl
import numpy

x = numpy.linspace(0, 2 * numpy.pi, 10)
y = numpy.sin(x)

fig = tpl.figure()
fig.plot(x, y, label="data", width=50, height=15)
fig.show()

produces

    1 +---------------------------------------+
  0.8 |    **     **                          |
  0.6 |   *         **           data ******* |
  0.4 | **                                    |
  0.2 |*              **                      |
    0 |                 **                    |
      |                                   *   |
 -0.2 |                   **            **    |
 -0.4 |                     **         *      |
 -0.6 |                              **       |
 -0.8 |                       **** **         |
   -1 +---------------------------------------+
      0     1    2     3     4     5    6     7

Horizontal histograms

import termplotlib as tpl
import numpy

numpy.random.seed(123)
sample = numpy.random.normal(size=1000)
counts, bin_edges = numpy.histogram(sample)

fig = tpl.figure()
fig.hist(counts, bin_edges, orientation="horizontal", force_ascii=False)
fig.show()

produces

hist1

Horizontal bar charts are covered as well. This

fig = tpl.figure()
fig.barh(
    [3, 10, 5, 2],
    ['Cats', 'Dogs', 'Cows', 'Geese'],
    force_ascii=True
)
fig.show()

produces

Cats   [ 3]  ************
Dogs   [10]  ****************************************
Cows   [ 5]  ********************
Geese  [ 2]  ********

Vertical histograms

import termplotlib as tpl
import numpy

numpy.random.seed(123)
sample = numpy.random.normal(size=1000)
counts, bin_edges = numpy.histogram(sample, bins=40)
fig = tpl.figure()
fig.hist(counts, bin_edges, grid=[15, 25], force_ascii=False)
fig.show()

produces

hist2

Tables

Support for tables has moved over to termtables.

Installation

termplotlib is available from the Python Package Index, so simply do

pip3 install -U termplotlib

to install or upgrade. Use sudo -H to install as root or the --user option of pip3 to install in $HOME.

Testing

To run the termplotlib unit tests, check out this repository and type

pytest

License

termplotlib is published under the MIT license.

You can’t perform that action at this time.