pyecharts之二

本文详细介绍了pyecharts库的使用,包括各种图表类型如柱状图、折线图、饼图的创建,以及如何自定义样式、交互功能和数据可视化效果,帮助读者深入理解pyecharts在数据展示中的应用。
摘要由CSDN通过智能技术生成
import pyecharts.charts as pyec
import pyecharts.options as opts

x=['甲','乙','丙']
y=[300,800,600]
bar=pyec.Bar()
bar.add_xaxis(x)
bar.add_yaxis(series_name='公司A',yaxis_data=y)
bar.render_notebook()
    <div id="c02ecfe266334305b289c711edf10ca0" style="width:900px; height:500px;"></div>

bar.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
bar.render_notebook()
    <div id="17b3970b2c444df99f3edffbf5d374af" style="width:900px; height:500px;"></div>
import pyecharts
pyecharts.__version__
'1.5.1'
#增加一个数据系列
y1 = [1200,500,200]
bar.add_yaxis(series_name = '公司B',yaxis_data=y1)
bar.render_notebook()

    <div id="c6c816b176a547c1814dc8d0f61c4dcd" style="width:900px; height:500px;"></div>
#条形图
bar.reversal_axis()
bar.render_notebook()
    <div id="68584656209e4ff08a8390e1c31b504b" style="width:900px; height:500px;"></div>
x1 = ['2017','2018','2019']
y1 = [300,900,600]
line = pyec.Line()
line.add_xaxis(x1)
line.add_yaxis(series_name = 'A',y_axis = y1)
#bar.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
line.render_notebook()
    <div id="e4e2c742cf7e472ea0b5528a00f187cb" style="width:900px; height:500px;"></div>
y2 = [1300,500,900]
line.add_yaxis(series_name='B',y_axis=y2)
line.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
line.render_notebook()
    <div id="bbb96d7096f34bcfa5f009601317abd9" style="width:900px; height:500px;"></div>
line.set_global_opts(title_opts=opts.TitleOpts(title = 'First'),legend_opts=opts.LegendOpts(is_show = True),tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross'))

line.render_notebook()
    <div id="8697ec090191497b85dc0db215402730" style="width:900px; height:500px;"></div>
line.set_global_opts(title_opts=opts.TitleOpts(title = 'First'),legend_opts=opts.LegendOpts(is_show = True),tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross'),toolbox_opts=opts.ToolboxOpts(is_show = True,orient='horizontal'),datazoom_opts=opts.DataZoomOpts(type_ = 'slider',range_start=(),range_end=2500))
#vertical,竖着放
line.render_notebook()
    <div id="80b28eacf45641eb882c77d71089cde2" style="width:900px; height:500px;"></div>
line1 = pyec.Line(init_opts=opts.InitOpts(width = '500px',height='300px'))
line1.add_xaxis(x1)
line1.add_yaxis(series_name = "A",y_axis = y1)

line1.render_notebook()
    <div id="6eaf199cc5424be499b01df66aa6fd23" style="width:500px; height:300px;"></div>
x_data = ['直接访问','营销推广','博客推广','搜索引擎']
y_data = [830,214,399,1199]

data_pair = list(zip(x_data,y_data))
print(data_pair)

[('直接访问', 830), ('营销推广', 214), ('博客推广', 399), ('搜索引擎', 1199)]
pie = pyec.Pie()
pie.add(series_name = '推广渠道',data_pair = data_pair)
pie.render_notebook()
    <div id="2d831b2ea8cf4ff69517684d06f63b5a" style="width:900px; height:500px;"></div>
pie1 = pyec.Pie()
pie1.add(series_name = '',data_pair = data_pair,radius = ['40%','75%'])
pie1.set_global_opts(title_opts=opts.TitleOpts(title =''))
pie1.render_notebook()
    <div id="f7f165b31bff4ed883472177fec09143" style="width:900px; height:500px;"></div>
#散点图
import numpy as np

x = np.linspace(0,10,30)
y1= np.sin(x
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值