使用utf-8字符和花式颜色的文本模式图
diagram的Python项目详细描述
图表
使用utf-8字符和花式颜色的文本模式图(使用python)。
功能
- 水平和垂直条形图
- 支持3位(16色)和8位(256色)模式颜色 各种预定义选项板(见下文)
- UTF-8文本图形
安装
Fedora Core 24的系统要求:
dnf install ncurses-devel ncurses-compat-libs
建议使用pip安装/更新。
要安装:
$ sudo pip install diagram
要更新:
$ sudo pip install -U diagram
从github安装:
$ sudo pip install git+https://github.com/tehmaze/diagram.git
示例
图片说一千多字。
< H3>轴图< EH3>水平条形图
使用的绘图字符:
▏ ▎ ▍ ▌ ▋ ▊ ▉ █
垂直条形图
使用的绘图字符:
▁ ▂ ▃ ▄ ▅ ▆ ▇ █
用法
在文档中使用diagram --help
:
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 ...
参数可以只是函数名或带有参数的函数名, 例如:
diagram -f log
或者,使用参数:
diagram -f log:e
日志
对称对数标度。
平滑
使用Savitzky Golay过滤器平滑(并可选地区分)数据。
--palette ...
默认/光谱
灰色
红色
绿色
蓝色
库使用
from diagram import DGWrapper
gram = DGWrapper(data=[points, values])
gram.show()