Skip to main content

# diagram

Text mode diagrams using UTF-8 characters and fancy colors (using Python).

[![Build Status][cib]][ci] [![Code Health][lsb]][ls]

[ci]: https://travis-ci.org/tehmaze/diagram [cib]: https://travis-ci.org/tehmaze/diagram.svg [ls]: https://landscape.io/github/tehmaze/diagram/issue/9/custom_colors [lsb]: https://landscape.io/github/tehmaze/diagram/issue/9/custom_colors/landscape.svg?style=flat

## Features

  • Axial graphs

  • Horizontal and vertical bar graphs

  • Supports both 3 bit (16 color) and 8 bit (256 color) mode colors with various pre-defined palettes (see below)

  • UTF-8 text graphics

## Installation

### System requirements for Fedora Core 24:

dnf install ncurses-devel ncurses-compat-libs

It’s recommended to use pip to install/update.

To install:

$ sudo pip install diagram

To update:

$ sudo pip install -U diagram

To install from github:

$ sudo pip install git+https://github.com/tehmaze/diagram.git

## Examples

Pictures say more than a thousand words.

### Axis graph

![Axis Graph](https://github.com/tehmaze/diagram/raw/master/doc/axisgraph.png)

### Horizontal bar graph

![Horizontal bar graph](https://github.com/tehmaze/diagram/raw/master/doc/horizontalbar.png)

Drawing characters used:

▏ ▎ ▍ ▌ ▋ ▊ ▉ █

### Vertical bar graph

![Vertical bar graph](https://github.com/tehmaze/diagram/raw/master/doc/verticalbar.png)

Drawing characters used:

▁ ▂ ▃ ▄ ▅ ▆ ▇ █

## Usage

Use diagram –help for documentation:

usage: diagram [-h] [-G] [-H] [-V] [-a] [-A] [-c] [-C] [-l] [-L]

[-f function] [-p palette] [-x characters] [-y characters] [-r] [-b] [-s SLEEP] [-i file] [-o file] [-e ENCODING]

optional arguments:
-h, --help

show this help message and exit

optional drawing mode:
-G, --graph

axis drawing mode (default)

-H, --horizontal-bars

horizontal drawing mode

-V, --vertical-bars

vertical drawing mode

optional drawing arguments:
-a, --axis

draw axis (default: yes)

-A, --no-axis

don’t draw axis

-c, --color

use colors (default: yes)

-C, --no-color

don’t use colors

-l, --legend

draw y-axis legend (default: yes)

-L, --no-legend

don’t draw y-axis legend

-f function, --function function

curve manipulation function, use “help” for a list

-p palette, --palette palette

palette name, use “help” for a list

-x characters, --width characters

drawing width (default: auto)

-y characters, --height characters

drawing height (default: auto)

-r, --reverse

reverse draw graph

optional input and output arguments:
-b, --batch

batch mode (default: no)

-k, --keys

input are key-value pairs (default: no) (1)

-s SLEEP, --sleep SLEEP

batch poll sleep time (default: none)

-i file, --input file

input file (default: stdin)

-o file, --output file

output file (default: stdout)

-e ENCODING, --encoding ENCODING

output encoding (default: auto)

(1): only works for the horizontal bar graph, the first argument is the key and the second value is the data point.

### –function …

The parameter can be just the function name or the function name with arguments, for example:

diagram -f log

or, with an argument:

diagram -f log:e

#### log

Symmetrical logarithmic scale.

#### smooth

Smooth (and optionally differentiate) data with a Savitzky-Golay filter.

### –palette …

#### default / spectrum

![Palette Spectrum](https://github.com/tehmaze/diagram/raw/master/doc/palette-spectrum.png)

#### grey

![Palette Grey](https://github.com/tehmaze/diagram/raw/master/doc/palette-grey.png)

#### red

![Palette Red](https://github.com/tehmaze/diagram/raw/master/doc/palette-red.png)

#### green

![Palette Green](https://github.com/tehmaze/diagram/raw/master/doc/palette-green.png)

#### blue

![Palette Blue](https://github.com/tehmaze/diagram/raw/master/doc/palette-blue.png)

## Library Usage

from diagram import DGWrapper gram = DGWrapper(data=[points, values]) gram.show()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diagram-0.2.28.tar.gz (96.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

diagram-0.2.28-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

diagram-0.2.28-py2-none-any.whl (14.5 kB view details)

Uploaded Python 2

File details

Details for the file diagram-0.2.28.tar.gz.

File metadata

  • Download URL: diagram-0.2.28.tar.gz
  • Upload date:
  • Size: 96.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.10

File hashes

Hashes for diagram-0.2.28.tar.gz
Algorithm Hash digest
SHA256 cad92799c4340bc57a757f598024779f4866fcda49f17764d0f148a57d3f9d5c
MD5 a287cd24236dd51cf0d261406659c1fe
BLAKE2b-256 6cbb98ad98f7e3df872729db276de7c6dd36a97a8c480651b2caf6dafaf051f4

See more details on using hashes here.

File details

Details for the file diagram-0.2.28-py3-none-any.whl.

File metadata

  • Download URL: diagram-0.2.28-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.10

File hashes

Hashes for diagram-0.2.28-py3-none-any.whl
Algorithm Hash digest
SHA256 996663dff771b6e45ed983647808caf89de22f7eb860b02822b31f85460729ab
MD5 9279769160622567be6daf0a3d4686b7
BLAKE2b-256 701694b01e4773cc4c23be369eb5b0b7de8a9f7e572672f40f5a1ca5d1b9e41b

See more details on using hashes here.

File details

Details for the file diagram-0.2.28-py2-none-any.whl.

File metadata

  • Download URL: diagram-0.2.28-py2-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.9.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.10

File hashes

Hashes for diagram-0.2.28-py2-none-any.whl
Algorithm Hash digest
SHA256 1d3529751c3b0c6437fa78abf91b6d5709cdc8a6a963c3e548c36dab7b607e41
MD5 1412855c94829b959678386d51e5ad46
BLAKE2b-256 a800adda52528ca8fcb99b73f828012be192256aa81ebab4bc864816141e3dd8

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.28 This release

3 files

0.2.27

3 files

0.2.25

2 files

0.2.24

2 files

0.2.23

1 file

0.2.22

1 file

0.2.21

1 file

0.1

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page