跳转到主要内容

使用UTF-8字符和鲜艳颜色进行文本模式图表

项目描述

# 图表

使用UTF-8字符和鲜艳颜色进行文本模式图表(使用Python)。

[![构建状态][cib]][ci] [![代码健康][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

## 功能

  • 轴图

  • 水平和垂直条形图

  • 支持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

## 示例

图片胜过千言万语。

### 轴图

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

### 水平条形图

![水平条形图](https://github.com/tehmaze/diagram/raw/master/doc/horizontalbar.png)

使用的绘图字符

▏ ▎ ▍ ▌ ▋ ▊ ▉ █

### 垂直条形图

![垂直条形图](https://github.com/tehmaze/diagram/raw/master/doc/verticalbar.png)

使用的绘图字符

▁ ▂ ▃ ▄ ▅ ▆ ▇ █

## 使用

使用 diagram –help 查看文档

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

[-f 函数] [-p 调色板] [-x 字符] [-y 字符] [-r] [-b] [-s SLEEP] [-i 文件] [-o 文件] [-e 编码]

可选参数
-h, --help

显示此帮助信息并退出

可选绘图模式
-G, --graph

轴绘图模式(默认)

-H, --horizontal-bars

水平绘图模式

-V, --vertical-bars

垂直绘图模式

可选绘图参数
-a, --axis

绘制轴(默认:是)

-A, --no-axis

不绘制轴

-c, --color

使用颜色(默认:是)

-C, --no-color

不使用颜色

-l, --legend

绘制y轴图例(默认:是)

-L, --no-legend

不绘制y轴图例

-f 函数, --function 函数

曲线操作函数,使用“帮助”查看列表

-p 调色板, --palette 调色板

调色板名称,使用“帮助”查看列表

-x 字符, --width 字符

绘图宽度(默认:自动)

-y 字符, --height 字符

绘图高度(默认:自动)

-r, --reverse

反转绘图图形

可选输入和输出参数
-b, --batch

批量模式(默认:否)

-k, --keys

输入为键值对(默认:否)(1)

-s SLEEP, --sleep SLEEP

批量轮询睡眠时间(默认:无)

-i 文件, --input 文件

输入文件(默认:stdin)

-o 文件, --output 文件

输出文件(默认:stdout)

-e 编码, --encoding 编码

输出编码(默认:自动)

(1): 仅适用于水平条形图,第一个参数是键,第二个参数是数据点。

### –function …

参数可以是函数名,也可以是带有参数的函数名,例如

diagram -f log

或者,带有参数的例子

diagram -f log:e

#### log

对称对数刻度。

#### smooth

使用Savitzky-Golay滤波器平滑(可选微分)数据。

### –palette …

#### default / spectrum

![调色板频谱](https://github.com/tehmaze/diagram/raw/master/doc/palette-spectrum.png)

#### grey

![调色板灰色](https://github.com/tehmaze/diagram/raw/master/doc/palette-grey.png)

#### red

![调色板红色](https://github.com/tehmaze/diagram/raw/master/doc/palette-red.png)

#### green

![调色板绿色](https://github.com/tehmaze/diagram/raw/master/doc/palette-green.png)

#### blue

![调色板蓝色](https://github.com/tehmaze/diagram/raw/master/doc/palette-blue.png)

## 库使用方法

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

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码发行版

diagram-0.2.28.tar.gz (96.5 kB 查看哈希值)

上传时间: 源代码

构建发行版

diagram-0.2.28-py3-none-any.whl (13.0 kB 查看哈希值)

上传时间: Python 3

diagram-0.2.28-py2-none-any.whl (14.5 kB 查看哈希值)

上传时间: Python 2

支持者