在命令行上打印

asciiplotlib的Python项目详细描述


asciiplotlib

CircleCIcodecovCode style: blackPyPi VersionGitHub starsPyPi downloads

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()

产生

hist1

水平条形图也包括在内。这个

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()

产生

hist2

表格

对表的支持已转移到 termtables

安装

asciplotlib是available from the Python Package Index,所以只要做

pip3 install -U asciiplotlib

安装或升级。使用sudo -H以根用户身份安装或--user选项 在pip3中安装。

测试

要运行asciplotlib单元测试,请签出此存储库并键入

pytest

许可证

asciplotlib在MIT license下发布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用户界面如何在JavaGUI中为按钮创建各种颜色?   使用MSCAPI的RSA密钥包装的java使用   java Spring数据Redis JedisConnectionException:意外的流结束   java饼图未显示预期输出   java hystrixCommand注释commandKey的用途是什么   windows java可以从cmd运行jar,但不能通过双击来运行   java在单击按钮时遍历XML节点   java试图使用日期(int,int,int)构造函数   带有Buildship 2子项目的java不作为项目依赖项链接   java jsonrpc4j:如何从服务器获取列表<SomeObject>?   用于Java应用程序的内存设置MaxDirectMemory和MaxHeapMemory   java如何从以下类型格式化日期   javayoutube。搜索列表搜索不返回任何内容   java My参数在方法中不起作用,因为泛型存在问题   java如何将Map<Key1Type,Val1Type>转换为Map<Key1Type,Val2Type>   JavaJUnit测试:测试用例的改进,测试数组列表的长度?   java如何在Android中解析带有属性值的xml数据?   使用Hibernate对枚举类型进行Java8bean验证