1. 基本示例

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values()).add_yaxis("商家B", Faker.values()).set_global_opts(title_opts=opts.TitleOpts(title="Line-基本示例")).render("line_base.html")
)

2. 缺失值的平滑处理

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakery = Faker.values()
y[3], y[5] = None, None
c = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", y, is_connect_nones=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-连接空数据")).render("line_connect_null.html")
)

3. markline

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A",Faker.values(),markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),).add_yaxis("商家B",Faker.values(),markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average")]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkLine")).render("line_markline.html")
)

4. markpoint

4.1 markpoint自定义

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerx, y = Faker.choose(), Faker.values()
c = (Line().add_xaxis(x).add_yaxis("商家A",y,markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(name="自定义标记点", coord=[x[2], y[2]], value=y[2])]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkPoint(自定义)")).render("line_markpoint_custom.html")
)

4.2 markpoint(最大值最小值)

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A",Faker.values(),markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="min")]),).add_yaxis("商家B",Faker.values(),markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max")]),).set_global_opts(title_opts=opts.TitleOpts(title="Line-MarkPoint")).render("line_markpoint.html")
)

5. 平滑曲线

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_smooth=True).add_yaxis("商家B", Faker.values(), is_smooth=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-smooth")).render("line_smooth.html")
)

6. 阶梯状

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_step=True).set_global_opts(title_opts=opts.TitleOpts(title="Line-阶梯图")).render("line_step.html")
)

7. 双x轴

import pyecharts.options as opts
from pyecharts.charts import Line# 将在 v1.1.0 中更改
from pyecharts.commons.utils import JsCode"""
Gallery 使用 pyecharts 1.0.0
参考地址: https://echarts.apache.org/examples/editor.html?c=multiple-x-axis目前无法实现的功能:1、暂无
"""js_formatter = """function (params) {console.log(params);return '降水量  ' + params.value + (params.seriesData.length ? ':' + params.seriesData[0].data : '');}"""(Line().add_xaxis(xaxis_data=["2016-1","2016-2","2016-3","2016-4","2016-5","2016-6","2016-7","2016-8","2016-9","2016-10","2016-11","2016-12",]).extend_axis(xaxis_data=["2015-1","2015-2","2015-3","2015-4","2015-5","2015-6","2015-7","2015-8","2015-9","2015-10","2015-11","2015-12",],xaxis=opts.AxisOpts(type_="category",axistick_opts=opts.AxisTickOpts(is_align_with_label=True),axisline_opts=opts.AxisLineOpts(is_on_zero=False, linestyle_opts=opts.LineStyleOpts(color="#6e9ef1")),axispointer_opts=opts.AxisPointerOpts(is_show=True, label=opts.LabelOpts(formatter=JsCode(js_formatter))),),).add_yaxis(series_name="2015 降水量",is_smooth=True,symbol="emptyCircle",is_symbol_show=False,# xaxis_index=1,color="#d14a61",y_axis=[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3],label_opts=opts.LabelOpts(is_show=False),linestyle_opts=opts.LineStyleOpts(width=2),).add_yaxis(series_name="2016 降水量",is_smooth=True,symbol="emptyCircle",is_symbol_show=False,color="#6e9ef1",y_axis=[3.9, 5.9, 11.1, 18.7, 48.3, 69.2, 231.6, 46.6, 55.4, 18.4, 10.3, 0.7],label_opts=opts.LabelOpts(is_show=False),linestyle_opts=opts.LineStyleOpts(width=2),).set_global_opts(legend_opts=opts.LegendOpts(),tooltip_opts=opts.TooltipOpts(trigger="none", axis_pointer_type="cross"),xaxis_opts=opts.AxisOpts(type_="category",axistick_opts=opts.AxisTickOpts(is_align_with_label=True),axisline_opts=opts.AxisLineOpts(is_on_zero=False, linestyle_opts=opts.LineStyleOpts(color="#d14a61")),axispointer_opts=opts.AxisPointerOpts(is_show=True, label=opts.LabelOpts(formatter=JsCode(js_formatter))),),yaxis_opts=opts.AxisOpts(type_="value",splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(opacity=1)),),).render("multiple_x_axes.html")
)

8. 多功能图

import pyecharts.options as opts
from pyecharts.charts import Line"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=line-marker目前无法实现的功能:1、最低气温的最高值暂时无法和 Echarts 的示例完全复刻
"""week_name_list = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
high_temperature = [11, 11, 15, 13, 12, 13, 10]
low_temperature = [1, -2, 2, 5, 3, 2, 0](Line().add_xaxis(xaxis_data=week_name_list).add_yaxis(series_name="最高气温",y_axis=high_temperature,markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(type_="max", name="最大值"),opts.MarkPointItem(type_="min", name="最小值"),]),markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average", name="平均值")]),).add_yaxis(series_name="最低气温",y_axis=low_temperature,markpoint_opts=opts.MarkPointOpts(data=[opts.MarkPointItem(value=-2, name="周最低", x=1, y=-1.5)]),markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(type_="average", name="平均值"),opts.MarkLineItem(symbol="none", x="90%", y="max"),opts.MarkLineItem(symbol="circle", type_="max", name="最高点"),]),).set_global_opts(title_opts=opts.TitleOpts(title="未来一周气温变化", subtitle="纯属虚构"),tooltip_opts=opts.TooltipOpts(trigger="axis"),toolbox_opts=opts.ToolboxOpts(is_show=True),xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),).render("temperature_change_line_chart.html")
)

9. 基本区域图

import pyecharts.options as opts
from pyecharts.charts import Line"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=area-basic目前无法实现的功能:暂无
"""x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
y_data = [820, 932, 901, 934, 1290, 1330, 1320](Line().add_xaxis(xaxis_data=x_data).add_yaxis(series_name="",y_axis=y_data,symbol="emptyCircle",is_symbol_show=True,label_opts=opts.LabelOpts(is_show=False),areastyle_opts=opts.AreaStyleOpts(opacity=1, color="#C67570"),).set_global_opts(tooltip_opts=opts.TooltipOpts(is_show=False),yaxis_opts=opts.AxisOpts(type_="value",axistick_opts=opts.AxisTickOpts(is_show=True),splitline_opts=opts.SplitLineOpts(is_show=True),),xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=False),)# 设置 boundary_gap 的时候一定要放在最后一个配置项里, 不然会被覆盖.render("basic_area_chart.html")
)

10. 不带数据值标注

import pyecharts.options as opts
from pyecharts.charts import Line"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=line-simple目前无法实现的功能:暂无
"""x_data = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
y_data = [820, 932, 901, 934, 1290, 1330, 1320](Line().set_global_opts(tooltip_opts=opts.TooltipOpts(is_show=False),xaxis_opts=opts.AxisOpts(type_="category"),yaxis_opts=opts.AxisOpts(type_="value",axistick_opts=opts.AxisTickOpts(is_show=True),splitline_opts=opts.SplitLineOpts(is_show=True),),).add_xaxis(xaxis_data=x_data).add_yaxis(series_name="",y_axis=y_data,symbol="emptyCircle",is_symbol_show=True,label_opts=opts.LabelOpts(is_show=False),).render("basic_line_chart.html")
)

11. 面积图

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), areastyle_opts=opts.AreaStyleOpts(opacity=0.5)).add_yaxis("商家B", Faker.values(), areastyle_opts=opts.AreaStyleOpts(opacity=0.5)).set_global_opts(title_opts=opts.TitleOpts(title="Line-面积图")).render("line_area_style.html")
)

面积图紧贴y轴

import pyecharts.options as opts
from pyecharts.charts import Line
from pyecharts.faker import Fakerc = (Line().add_xaxis(Faker.choose()).add_yaxis("商家A", Faker.values(), is_smooth=True).add_yaxis("商家B", Faker.values(), is_smooth=True).set_series_opts(areastyle_opts=opts.AreaStyleOpts(opacity=0.5),label_opts=opts.LabelOpts(is_show=False),).set_global_opts(title_opts=opts.TitleOpts(title="Line-面积图(紧贴 Y 轴)"),xaxis_opts=opts.AxisOpts(axistick_opts=opts.AxisTickOpts(is_align_with_label=True),is_scale=False,boundary_gap=False,),).render("line_areastyle_boundary_gap.html")
)

炫彩图

import pyecharts.options as opts
from pyecharts.charts import Line, Grid
from pyecharts.commons.utils import JsCode"""
参考地址: https://gallery.echartsjs.com/editor.html?c=xEyDk1hwBx
"""x_data = ["14", "15", "16", "17", "18", "19", "20", "21", "22", "23"]
y_data = [393, 438, 485, 631, 689, 824, 987, 1000, 1100, 1200]background_color_js = ("new echarts.graphic.LinearGradient(0, 0, 0, 1, ""[{offset: 0, color: '#c86589'}, {offset: 1, color: '#06a7ff'}], false)"
)
area_color_js = ("new echarts.graphic.LinearGradient(0, 0, 0, 1, ""[{offset: 0, color: '#eb64fb'}, {offset: 1, color: '#3fbbff0d'}], false)"
)c = (Line(init_opts=opts.InitOpts(bg_color=JsCode(background_color_js))).add_xaxis(xaxis_data=x_data).add_yaxis(series_name="注册总量",y_axis=y_data,is_smooth=True,is_symbol_show=True,symbol="circle",symbol_size=6,linestyle_opts=opts.LineStyleOpts(color="#fff"),label_opts=opts.LabelOpts(is_show=True, position="top", color="white"),itemstyle_opts=opts.ItemStyleOpts(color="red", border_color="#fff", border_width=3),tooltip_opts=opts.TooltipOpts(is_show=False),areastyle_opts=opts.AreaStyleOpts(color=JsCode(area_color_js), opacity=1),).set_global_opts(title_opts=opts.TitleOpts(title="OCTOBER 2015",pos_bottom="5%",pos_left="center",title_textstyle_opts=opts.TextStyleOpts(color="#fff", font_size=16),),xaxis_opts=opts.AxisOpts(type_="category",boundary_gap=False,axislabel_opts=opts.LabelOpts(margin=30, color="#ffffff63"),axisline_opts=opts.AxisLineOpts(is_show=False),axistick_opts=opts.AxisTickOpts(is_show=True,length=25,linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),),splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")),),yaxis_opts=opts.AxisOpts(type_="value",position="right",axislabel_opts=opts.LabelOpts(margin=20, color="#ffffff63"),axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts(width=2, color="#fff")),axistick_opts=opts.AxisTickOpts(is_show=True,length=15,linestyle_opts=opts.LineStyleOpts(color="#ffffff1f"),),splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(color="#ffffff1f")),),legend_opts=opts.LegendOpts(is_show=False),)
)(Grid().add(c,grid_opts=opts.GridOpts(pos_top="20%",pos_left="10%",pos_right="10%",pos_bottom="15%",is_contain_label=True,),).render("beautiful_line_chart.html")
)

xxx

import pyecharts.options as opts
from pyecharts.charts import Line"""
Gallery 使用 pyecharts 1.1.0
参考地址: https://echarts.apache.org/examples/editor.html?c=line-sections目前无法实现的功能:1、visualMap 暂时无法设置隐藏
"""x_data = ["00:00","01:15","02:30","03:45","05:00","06:15","07:30","08:45","10:00","11:15","12:30","13:45","15:00","16:15","17:30","18:45","20:00","21:15","22:30","23:45",
]
y_data = [300,280,250,260,270,300,550,500,400,390,380,390,400,500,600,750,800,700,600,400,
](Line().add_xaxis(xaxis_data=x_data).add_yaxis(series_name="用电量",y_axis=y_data,is_smooth=True,label_opts=opts.LabelOpts(is_show=False),linestyle_opts=opts.LineStyleOpts(width=2),).set_global_opts(title_opts=opts.TitleOpts(title="一天用电量分布", subtitle="纯属虚构"),tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"),xaxis_opts=opts.AxisOpts(boundary_gap=False),yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} W"),splitline_opts=opts.SplitLineOpts(is_show=True),),visualmap_opts=opts.VisualMapOpts(is_piecewise=True,dimension=0,pieces=[{"lte": 6, "color": "green"},{"gt": 6, "lte": 8, "color": "red"},{"gt": 8, "lte": 14, "color": "green"},{"gt": 14, "lte": 17, "color": "red"},{"gt": 17, "color": "green"},],),).set_series_opts(markarea_opts=opts.MarkAreaOpts(data=[opts.MarkAreaItem(name="早高峰", x=("07:30", "10:00")),opts.MarkAreaItem(name="晚高峰", x=("17:30", "21:15")),])).render("distribution_of_electricity.html")
)

pyecharts-折线图相关推荐

  1. 解决 pyecharts 折线图数字标签设置 formatter 参数后标签内容有问题

    解决问题 pyecharts 做折线图的时候,当我们对每个点的数值标签进行设置后,他自动带上了x轴的信息. 问题呈现:pyecharts 折线图 下面代码由于对标签进行了的格式化设置,导致出来的图中把 ...

  2. python数据分析——pyecharts折线图全解

    折线图是排列在工作表的列或行中的数据可以绘制到折线图中.折线图可以显示随时间(根据常用比例设置)而变化的连续数据,因此非常适用于显示在相等时间间隔下数据的趋势. 下面我给大家介绍一下如何用pyecha ...

  3. python pyecharts 折线图_python数据大屏pyecharts库2020.8.31

    数据大屏V0.1-2020.8.31 前言 千辛万苦,找到了python能实现数据大屏库pyecharts. 1.https://gallery.pyecharts.org/#/Page/page_s ...

  4. python pyecharts 折线图_Python数据可视化之pyecharts实现各种图表

    之前的一篇文章介绍了使用Matplotlib实现各种统计图表,Python数据可视化之Matplotlib实现各种图表.这篇文章就介绍使用pyecharts实现各种统计图表. 1.pyecharts介 ...

  5. Pyecharts 折线图与堆积柱状图结合的组合图绘画,折线图数据点在柱状图柱中心

    问题/背景 最近因科研需要,开始浅浅学习pyecharts,并记录在这个过程遇到的问题以及简单的解决办法. 在使用pyecharts画组合图时遇到了折线图的点无法对准柱状图中心的问题,在网上的文章只找 ...

  6. [数据分析笔记] 网易云歌单分析系列03—pyecharts折线图

    0.导入数据 import numpy as np import pandas as pd import pymysql from pyecharts import options as opts f ...

  7. pyecharts折线图上symbol(小圆圈)颜色的修改方法

    本人刚接触pyecharts,尝试做k线与指标图,但遇到不少困难. 虽然pyecharts虽在展现上令人舒畅,但使用起来并不能像echarts那么完善,比如k线的颜色目前就改不了,我是在尝试了各种方法 ...

  8. 用Python pyecharts v1.x 绘制图形(二):折线图、折线面积图、散点图、雷达图、箱线图、词云图

    文章目录 关于pyecharts 折线图 折线面积图 散点图 雷达图 箱线图 词云图 其他 关于pyecharts pyecharts是一个用于生成echart(百度开源的数据可视化javascrip ...

  9. python做动态折线图_Python数据可视化 pyecharts实现各种统计图表过程详解

    1.pyecharts介绍 Echarts是一款由百度公司开发的开源数据可视化JS库,pyecharts是一款使用python调用echarts生成数据可视化的类库,可实现柱状图,折线图,饼状图,地图 ...

  10. echarts控制只显示部分数据的折线图_Python数据可视化之pyecharts入门

    Echarts是一个开源的数据可视化JS库,pyecharts是一个生成Echarts图表的python类库.在使用pyecharts,首先我们需要安装pyechats类库. pip install ...

最新文章

  1. 宏EXPORT_SYMBOL在内核中的作用
  2. 游戏光线追踪往事:十年技术轮回
  3. Azkaban使用简单笔记
  4. Entity Framework Core 执行SQL语句和存储过程
  5. 计算机有什么著名基金经理排名,百万年薪的基金经理,都是什么专业出身?!...
  6. JAVA ------- eclipse使用的步骤: %## 使用小技巧 ##%
  7. 从入门到入土:基于C语言采用UDP协议实现远程控制|详细说明|利用流套接字实现一个简单的远程控制系统|代码展示
  8. js 难点之原型理解
  9. linux服务器用的多的命令,linux服务器常用命令
  10. java--cmd乱码
  11. 怠惰是贫穷的制造厂 jzoj 2017.8.18 B组
  12. 咸阳强生告诉你吃什么食物养胃效果好
  13. ucore lab1 任务六
  14. js 下拉层级多选_Jquery实现select二级联动多选下拉菜单
  15. OLED屏幕花屏的原因(I2C+DMA)
  16. Linux下自动化运维工具ansible
  17. 量化投资学习必读书目(八)——《短线交易大师》
  18. 怎样将几个pdf文件合成一个?
  19. html中,table 的cellpadding cellspacing 属性失效
  20. 让家庭机器人成标配,我们还需要等多久?

热门文章

  1. 什么是数据库?数据库分为哪几种?
  2. java程序无法访问远程数据库或远程服务(VPN)
  3. 解决逃离塔科夫0.12.9离线版修改商人可回收所有物品的问题
  4. spring源码分析3,java技术面试评语及录用建议
  5. Nodejs安装教程(全套教程保姆级)
  6. C#数据类型和类型转换 Convert.ToInt16 与 Convert.ToInt32 区别
  7. logistic回归和softmax回归
  8. 转:上午还在写Bug,下午突然“被离职”,咋整?
  9. Python爬虫从入门到精通:(9)数据解析_xpath解析2_爬取4K高清动漫图片_Python涛哥
  10. 【工程数学】笔记1:复变函数和积分变换