在命令行上打印
asciiplotlib的Python项目详细描述
asciiplotlib
asciplotlib是一个python 3库,可以满足所有终端打印需求。它的目标是工作 就像matplotlib。
线图
对于线图,asciplotlib依赖于gnuplot。安装后,代码
importasciiplotlibasaplimportnumpyx=numpy.linspace(0,2*numpy.pi,10)y=numpy.sin(x)fig=apl.figure()fig.plot(x,y,label="data",width=50,height=15)fig.show()
产生
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
水平直方图
importasciiplotlibasaplimportnumpynumpy.random.seed(123)sample=numpy.random.normal(size=1000)counts,bin_edges=numpy.histogram(sample)fig=apl.figure()fig.hist(counts,bin_edges,orientation="horizontal",force_ascii=False)fig.show()
产生
水平条形图也包括在内。这个
fig=apl.figure()fig.barh([3,10,5,2],['Cats','Dogs','Cows','Geese'],force_ascii=True)fig.show()
产生
Cats [ 3] ************
Dogs [10] ****************************************
Cows [ 5] ********************
Geese [ 2] ********
垂直直方图
importasciiplotlibasaplimportnumpynumpy.random.seed(123)sample=numpy.random.normal(size=1000)counts,bin_edges=numpy.histogram(sample,bins=40)fig=apl.figure()fig.hist(counts,bin_edges,grid=[15,25],force_ascii=False)fig.show()
产生
表格
对表的支持已转移到 termtables。
安装
asciplotlib是available from the Python Package Index,所以只要做
pip3 install -U asciiplotlib
安装或升级。使用sudo -H
以根用户身份安装或--user
选项
在pip3
中安装。
测试
要运行asciplotlib单元测试,请签出此存储库并键入
pytest
许可证
asciplotlib在MIT license下发布。