python 面积图设置y轴_pyecharts v1 版本 学习笔记 折线图,面积图

这篇博客介绍了如何使用pyecharts库在Python中创建折线图和面积图,包括基本示例、平滑曲线、空数据连接、面积图、紧贴y轴的曲线表示、对数轴显示以及平均值和最大值的标记。通过示例代码展示了如何设置y轴、添加数据、调整样式等操作。
摘要由CSDN通过智能技术生成

折线图

折线图 基本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()

折线图 如果有空数据连接

importpyecharts.options as optsfrom pyecharts.charts importLine

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

平滑曲线展示

importpyecharts.options as optsfrom pyecharts.charts importLine

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

面积图:

importpyecharts.options as optsfrom pyecharts.charts importLine

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轴)  曲线表示

importpyecharts.options as optsfrom pyecharts.charts importLine

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

对数轴显示  等比

importpyecharts.options as optsfrom pyecharts.charts importLine

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

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

importpyecharts.options as optsfrom pyecharts.charts importLine

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值