pyecharts v1 版本 学习笔记 折线图,面积图

感情迁移 提交于 2020-07-29 09:43:41

折线图

 

折线图 基本demo

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
Line()
.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
.add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105])
.add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49])
.set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例"))
)
c.render_notebook()








 

 

折线图 如果有空数据连接

 

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
       .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
     .add_yaxis('商家A', [114, 55, 27, 101, 125, None, 105],is_connect_nones=True)
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49],is_connect_nones=True)
        .set_global_opts(title_opts=opts.TitleOpts(title="Line连接空数据"))
    )
c.render_notebook()

 

 

 

平滑曲线展示

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
       .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
     .add_yaxis('商家A', [114, 55, 27, 101, 125, None, 105], is_smooth=True,is_connect_nones=True)
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49], is_smooth=True)
       .set_global_opts(title_opts=opts.TitleOpts(title="Line-smooth"))
    )
c.render_notebook()

 

 

 

 

 

 

面积图:

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
       .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
     .add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105], areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49], areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
        .set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例"))
    )
c.render_notebook()

 

 

 

 

line 面积图 (紧贴y轴)  曲线表示

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
       .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
     .add_yaxis('商家A', [114, 55, 27, 101, 125, 27, 105],is_smooth=True, areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
       .add_yaxis('商家B',[57, 134, 137, 129, 145, 60, 49], is_smooth=True, areastyle_opts=opts.AreaStyleOpts(opacity=0.5))
        .set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例"),
                   xaxis_opts=opts.AxisOpts(
                axistick_opts=opts.AxisTickOpts(is_align_with_label=True),
                is_scale=False,
                boundary_gap=False,
            )     )
    ).set_series_opts(
            areastyle_opts=opts.AreaStyleOpts(opacity=0.5),
            label_opts=opts.LabelOpts(is_show=False),
        )
c.render_notebook()

 

 

 

 

对数轴显示  等比

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
        .add_xaxis(xaxis_data=["", "", "", "", "", "", "", "", ""])
        .add_yaxis(
            "2 的指数",
            y_axis=[1, 2, 4, 8, 16, 32, 64, 128, 256],
            linestyle_opts=opts.LineStyleOpts(width=2),
        )
        .add_yaxis(
            "3 的指数",
            y_axis=[1, 3, 9, 27, 81, 247, 741, 2223, 6669],
            linestyle_opts=opts.LineStyleOpts(width=2),
        )
        .set_global_opts(
            title_opts=opts.TitleOpts(title="Line-对数轴示例"),
            xaxis_opts=opts.AxisOpts(name="x"),
            yaxis_opts=opts.AxisOpts(
                type_="log",
                name="y",
                splitline_opts=opts.SplitLineOpts(is_show=True),
                is_scale=True,
            ),
        )
    )
c.render_notebook()

 

 

 

 

line-markline  平均值

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
Line()
.add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
.add_yaxis(
"商家A",
[114, 55, 27, 101, 125, 27, 105],
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),
)
.add_yaxis(
"商家B",
[57, 134, 137, 129, 145, 60, 49],
markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),
)
.set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkLine"))
)
c.render_notebook()
















 

 

 

 

 

混合使用折线图  最大值,最小值 平均值(着重标注)

import pyecharts.options as opts
from pyecharts.charts import Line
c = (
        Line()
        .add_xaxis(["衬衫", "毛衣", "领带", "裤子", "风衣", "高跟鞋", "袜子"])
        .add_yaxis(
            "商家A",
            [114, 55, 27, 101, 125, 27, 105],
#             markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),
             markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),
            markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max"),opts.MarkPointItem(type_="min")]),  #点出来
         
        )
        .add_yaxis(
            "商家B",
            [57, 134, 137, 129, 145, 60, 49],
            markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="max")]),
        )
        .set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkLine"))
    )
c.render_notebook()

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!