Pyecharts 绘制基本图 快速上手
折线图
from pyecharts.charts import Line
import pyecharts.options as opts
x=['a','b','c','d','e','f']
y=[10,12,26,23,25,25]
y2=[41,92,15,34,25,45]
c=(
    Line()
    .add_xaxis(x)
    
    .add_yaxis('利润',y,is_step=True)
    
    .add_yaxis('销售',y2,is_smooth=True)
    .set_global_opts(
        
        title_opts=opts.TitleOpts(title='商品利润折线图',subtitle='2021年'),
        legend_opts=opts.LegendOpts(is_show=True)
        
        
    )
    .render('1.html')
)

条形图
from pyecharts.charts import Bar
import pyecharts.options as opts
x=['aaaa','bbbb','cccc','dddd']
y=[10,12,26,23]
c=(
    Bar()
    .add_xaxis(x)
    .add_yaxis('利润',y)
    .add_yaxis('利润2',y)
    .set_global_opts(
        title_opts=opts.TitleOpts(title='2021'),
        
        xaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(rotate=45)),
        legend_opts=opts.LegendOpts(is_show=True)
        
        
    )
    .render('2.html')
)

箱型图
from pyecharts.charts import Boxplot
import pyecharts.options as opts
x=['2021年']
y=[10,12,26,23,25,25]
y1=[10,12,66,23,25,15]
y2=[30,12,26,23,45,25]
y3=[10,22,26,23,25,23]
c=(
    Boxplot()
    .add_xaxis(x)
    .add_yaxis('利润',Boxplot.prepare_data([y]))
    .add_yaxis('利润1',Boxplot.prepare_data([y1]))
    .add_yaxis('利润2',Boxplot.prepare_data([y2]))
    .add_yaxis('利润3',Boxplot.prepare_data([y3]))
    .set_global_opts(title_opts=opts.TitleOpts(title='2021'))
    .render('3.html')
)

涟漪散点图
from pyecharts.charts import EffectScatter
import pyecharts.options as opts
from pyecharts.globals import SymbolType
x=['a','b','c','d','e','f']
y=[10,12,26,23,25,25]
c=(
    EffectScatter()
    .add_xaxis(x)
    
    .add_yaxis("1",y)
    
    
    
    
    
    
    
    
    
    
    .render('4.html')
)

K线图
from pyecharts.charts import Kline
import pyecharts.options as opts
x = ['a', 'b', 'c', 'd', 'e', 'f']
y = [[2320.26, 2320.26, 2287.3, 2362.94],
     [2300, 2291.3, 2288.26, 2308.38],
     [2295.35, 2346.5, 2295.35, 2345.92],
     [2347.22, 2358.98, 2337.35, 2363.8],
     [2360.75, 2382.48, 2347.89, 2383.76],
     [2383.43, 2385.42, 2371.23, 2391.82]]
c = (
    Kline()
    .add_xaxis(x)
    .add_yaxis('', y)
    .set_global_opts(title_opts=opts.TitleOpts(title='k线图'))
    .render('5.html')
)

重叠多图
import pyecharts.options as opts
from pyecharts.charts import Bar,Line
x=['a','b','c','d']
y=[10,12,26,23]
y1=[12,14,28,25]
c=(
    Bar()
    .add_xaxis(x)
    .add_yaxis('',y)
)
d=(
    Line()
    .add_xaxis(x)
    .add_yaxis('',y1)
)
c.overlap(d)
c.render('6.html')
