pyecharts可视化 发表于 2020-04-20 | 分类于 python | 热度 ℃ | 字数统计 539 字 | 阅读时长 3 分钟 pyecharts中的常用可视化工具。 http://pyecharts.org/#/zh-cn/ 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217from pyecharts import options as optsfrom pyecharts.faker import Fakerfrom pyecharts.charts import Bar, Bar3D, Line, Pie, EffectScatter, Funnel, Geo, Liquid, Radar, WordCloudfrom pyecharts.globals import ThemeType, SymbolTypeimport randombar = Bar( init_opts=opts.InitOpts( theme=ThemeType.PURPLE_PASSION, width='720px', height='540px'))bar.add_xaxis(Faker.choose())bar.add_yaxis('商家', Faker.values())# bar.add_yaxis('商家1', Faker.values(), stack='stack1')# bar.add_yaxis('商家2', Faker.values(), stack='stack1')# bar.add_yaxis('商家3', Faker.values(), stack='stack2')# bar.add_yaxis('商家4', Faker.values(), stack='stack2')bar.set_global_opts( title_opts=opts.TitleOpts( title='Bar1', subtitle='副标题'), datazoom_opts=[opts.DataZoomOpts()], xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=30)))bar.set_series_opts( label_opts=opts.LabelOpts(is_show=False), markpoint_opts=opts.MarkPointOpts( data=[ opts.MarkPointItem(type_='max', name='最大值'), opts.MarkPointItem(type_='min', name='最小值') ] ), markline_opts=opts.MarkPointOpts( data=[ opts.MarkLineItem(type_='average', name='平均值') ] ))bar.reversal_axis()bar.render()data = [(i, j, random.randint(0, 12)) for i in range(24) for j in range(6)]bar3d = Bar3D()bar3d.add( "", data, xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_='category'), yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_='category'), zaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_='value'))bar3d.set_global_opts( visualmap_opts=opts.VisualMapOpts(max_=20), title_opts=opts.TitleOpts(title='Bar3D'))bar3d.render()line = Line()line.add_xaxis(Faker.choose())line.add_yaxis( '商家1', Faker.values(), is_smooth=True, areastyle_opts=opts.AreaStyleOpts( opacity=0.2, color={ 'type': 'linear', 'x': 0, 'y': 0, 'x2': 0, 'x2': 1, 'colorStops': [{ 'offset': 0, 'color': 'red' }, { 'offset': 1, 'color': 'blue' }] } ))line.add_yaxis('商家2', Faker.values())line.set_global_opts( title_opts=opts.TitleOpts( title='line1', subtitle='副标题' ))line.render()pie = Pie()pie.add("", [list(z) for z in zip(Faker.choose(), Faker.values())], radius=['40%', '75%'], rosetype="area")pie.set_global_opts( title_opts=opts.TitleOpts( title='Pie1', subtitle='副标题'))pie.set_series_opts( label_opts=opts.LabelOpts(formatter='{b}:{c}'))pie.render()effect_scatter = EffectScatter()effect_scatter.add_xaxis(Faker.choose())effect_scatter.add_yaxis( '', Faker.values(), symbol=SymbolType.ARROW)effect_scatter.set_global_opts( title_opts=opts.TitleOpts( title='effect_scatter2', subtitle='副标题' ))effect_scatter.render()funnel = Funnel()funnel.add( '用户转化率', [list(z) for z in zip(Faker.choose(), Faker.values())], label_opts=opts.LabelOpts(position='inside'))funnel.set_global_opts( title_opts=opts.TitleOpts( title='funnel1', subtitle='副标题' ))funnel.render()geo = Geo()geo.add_schema(maptype='china')geo.add('geo', [list(z) for z in zip(Faker.provinces, Faker.values())])geo.set_series_opts(label_opts=opts.LabelOpts(is_show=False))geo.set_global_opts( visualmap_opts=opts.VisualMapOpts(), title_opts=opts.TitleOpts( title='funnel1', subtitle='副标题' ))geo.render()liquid = Liquid()liquid.add('liquid', [0.7, 0.6, 0.5])liquid.set_global_opts( title_opts=opts.TitleOpts( title='funnel1', subtitle='副标题' ))liquid.render()radar = Radar()radar.add_schema( schema=[ opts.RadarIndicatorItem(name='a', max_=6500), opts.RadarIndicatorItem(name='b', max_=5500), opts.RadarIndicatorItem(name='c', max_=4500), opts.RadarIndicatorItem(name='d', max_=3500), ])# radar.add('G', v1)# radar.add('H', v)radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False))radar.set_global_opts( title_opts=opts.TitleOpts( title='funnel1', subtitle='副标题' ))radar.render()words = [ ('aaaaaaa', 10000), ('bbbb', 20000), ('ccc', 30000)]wordcloud = WordCloud()wordcloud.add('', words, word_size_range=[20, 100])wordcloud.set_global_opts( title_opts=opts.TitleOpts( title='funnel1', subtitle='副标题' ))wordcloud.render() donate the author Donate WeChat Pay Alipay