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)
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 ) )
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