• Stars
    star
    669
  • Rank 67,451 (Top 2 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ“ˆ Plotting on the command line

termplotlib

PyPi Version PyPI pyversions GitHub stars PyPi downloads

gh-actions codecov LGTM Code style: black

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 as np

x = np.linspace(0, 2 * np.pi, 10)
y = np.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 as np

rng = np.random.default_rng(123)
sample = rng.standard_normal(size=1000)
counts, bin_edges = np.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

import termplotlib as tpl

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 as np

rng = np.random.default_rng(123)
sample = rng.standard_normal(size=1000)
counts, bin_edges = np.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

pip install termplotlib

to install.

Testing

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

pytest

Similar projects

More Repositories

1

tikzplotlib

πŸ“Š Save matplotlib figures as TikZ/PGFplots for smooth integration into LaTeX.
Python
2,398
star
2

meshio

πŸ•ΈοΈ input/output for many mesh formats
Python
1,930
star
3

tiptop

πŸ–₯️ Command-line system monitoring
Python
1,749
star
4

tuna

🐟 Python profile viewer
Python
1,363
star
5

perfplot

πŸ“ˆ Performance analysis for Python snippets
Python
1,339
star
6

awesome-scientific-computing

😎 Curated list of awesome software for numerical analysis and scientific computing
Python
1,319
star
7

pygmsh

πŸ•ΈοΈ Gmsh for Python
Python
844
star
8

matplotx

πŸ“Š More styles and useful extensions for Matplotlib
Python
789
star
9

colorio

🌈 Tools for color research
TeX
320
star
10

stressberry

Stress tests for the Raspberry Pi πŸ˜…
Python
319
star
11

github-trends

πŸ“ˆ GitHub star history plots
260
star
12

dufte

πŸ“ˆ Minimalistic Matplotlib style
Python
216
star
13

deadlink

πŸ’€ Checks and fixes URLs in code and documentation.
Python
162
star
14

cplot

🌈 Plot complex functions
Python
149
star
15

termtables

πŸ–₯️ Pretty tables in the terminal
Python
98
star
16

pytest-codeblocks

πŸ“„ Test code blocks in your READMEs
Python
95
star
17

action-cached-lfs-checkout

GitHub checkout action with LFS files pulled from cache
Just
90
star
18

ua-beamer

A LaTeX beamer theme for the University of Antwerp
TeX
75
star
19

pipdate

Small pip update helpers.
Python
73
star
20

matlab-guidelines

Guidelines for writing clean and fast code in MATLAB
TeX
67
star
21

spectro

🎡 Audio file analysis
Python
47
star
22

tablign

Aligns columns in your ASCII tables on the command line or in vim.
Python
43
star
23

pyfoobar

Python project template/scaffold and best practices
Python
41
star
24

betterspy

πŸ‘€ Visualization for SciPy sparse matrices.
Python
40
star
25

color-data

🌈 Collected experimental data for color research
Python
39
star
26

stackoverflow-trends

πŸ“ˆ StackOverflow trends
35
star
27

xhub

πŸ“ GitHub with LaTeX math, diagrams, etc.
JavaScript
35
star
28

maelstrom

Numerical simulation of magnetohydrodynamics.
Python
33
star
29

purple-pi

πŸ’œ LaTeX math wherever you want
JavaScript
31
star
30

stackoverflow-card

JavaScript
31
star
31

markdown-math-acid-test

Showcase GitHub math bugs
25
star
32

fontman

Manage and update your installed fonts.
Python
21
star
33

tau

The better pi
Python
20
star
34

pyfma

Fused multiply-add (with a single rounding) for Python.
Python
20
star
35

scipyx

SciPy fixes and extensions
Python
18
star
36

gitfaces

Fetch contributor avatars for a GitHub repository
Python
17
star
37

epicycler

Create epicycle animations.
Python
15
star
38

fjson

Python JSON writer with formatted floats
Python
14
star
39

python-vs-cpp

C++
13
star
40

identinum

Identify exact expression for decimal.
Python
9
star
41

mikado

Friendly solver interfaces for Trilinos.
C++
8
star
42

materials

Density, magnetic permeability etc. for a range of materials.
Python
8
star
43

note-on-cam16

Algorithmic improvements for the CIECAM02 and CAM16 color appearence models
TeX
8
star
44

matheon-html5-template

Matheon HTML5 presentation template
JavaScript
8
star
45

flow

Navier-Stokes and heat equation with FEniCS.
Python
5
star
46

nosh

A numerical solver for nonlinear SchrΓΆdinger equations
C++
4
star
47

tex-font-errors-cheatsheet

Cheat sheet(s) for decoding the meaning of TeX font errors
3
star
48

rhino

Python
3
star
49

vandermonde

πŸ“ Tools for working with Vandermonde matrices, e.g., BjΓΆrck-Pereyra.
Python
3
star
50

keygen_licensing_tools

Tools for license valididation with Keygen.sh
Python
3
star
51

corona-charts

Corona data and charts, updated automatically
Python
2
star
52

plm

Python
2
star
53

math-test

2
star
54

github-mathml-test

2
star
55

parabolic

Time stepping methods for parabolic problems.
Python
2
star
56

sippp

Fortran library for the solution of singularly perturbed parabolic problems
Fortran
2
star
57

nschloe.github.io

HTML
2
star
58

hanoi-material

Class material for nonlinear optimization at Hanoi Autumn School 2013
MATLAB
2
star
59

talk-python-scientific

Python in Scientific Computation
JavaScript
2
star
60

trilinos-tutorial

C++
1
star
61

tspsolve

Solution algorithms for the travelling salesman problem.
Python
1
star
62

launchpadtools

Tools for submitting packages to Ubuntu Launchpad
Python
1
star
63

nschloe

about me
1
star