Vegas--the missing matplotlib for scala

来源:互联网 发布:u盘数据丢失怎么恢复 编辑:程序博客网 时间:2024/05/18 03:34

最近有个任务,需要把scala中聚类的实验结果用scala展示出来,由于scala 本身没有提供matplotlib 的库,于是就寻找第三方的,看看有没有提供支持scala 画散点图的库 终于发现了Vegas.
Vegas 的 git 地址为

https://github.com/vegas-viz/Vegas
使用Vegas 也很简单 只要值pom文件中加入Vegas的依赖即可

<dependency>    <groupId>org.vegas-viz</groupId>    <artifactId>vegas_2.11</artifactId>    <version>0.3.6</version></dependency>
 import vegas._import vegas.render.WindowRenderer._val plot = Vegas("Results").  withData(    Seq(      Map("x" -> 1, "y" -> 1,"Origin"->"a"),      Map("x" -> 2, "y" -> 2,"Origin"->"b"),      Map("x" -> 3, "y" -> 3,"Origin"->"c")    )  ).  encodeX("x", Quant).  encodeY("y", Quant).  encodeColor(field="Origin", dataType= Nominal).  mark(Point)    plot.show

这里写图片描述

0 0
原创粉丝点击