D3py是一个基于D3的Pytho绘图库,可以像D3那样画出可交互的漂亮图形。
D3py的目的是把来自命令行或者脚本的数据画到浏览器窗口,d3py通过构建两个优秀的包来实现这一点。第一个是d3.js(MikeBostock),它是一个用于创建数据驱动文档的JavaScript库,允许将任意svg放置到浏览器窗口中。第二个是使用DataFrame数据结构的padasPytho模块(WesMckiey)。
示例import d3pyimport padasimport umpy as p# some test dataT = 100# this is a data frame with three colums (we oly use 2)df = padas.DataFrame({ "time" : rage(T), "pressure": p.radom.rad(T), "temp" : p.radom.rad(T)})## build up a figure, ggplot2 style# istatiate the figure objectfig = d3py.PadasFigure(df, ame="basic_example", width=300, height=300) # add some red poitsfig += d3py.geoms.Poit(x="pressure", y="temp", fill="red")# writes 3 files, starts up a server, the draws some beautiful poits i Chromefig.show()
评论