今天,我们介绍一款python中画图神器,之所以这么说是因为它确实方便好用,比matplotlib更好。matplotlib更倾向于科学计算及画图,而pyecharts则是全面开花、火力全开,能够打造一些炫酷的效果。我们用一个简单的例子来看看这款神器怎样?(以下所用pyecharts版本为V1.0.X )
一个简单的销售柱状图:
from pyecharts.charts import Barfrom pyecharts import options as optsbar = Bar()bar.add_xaxis(["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"])bar.add_yaxis("商家A", [5, 20, 36, 10, 75, 90])bar.add_yaxis('商家B',[6,18,30,5,69,80])bar.set_global_opts(title_opts=opts.TitleOpts(title="商品销量对比图", subtitle="XXX市场"))bar.render(‘mycharts.html’)
运行效果为: