01折线图---pyecharts

网友投稿 857 2022-10-08

01折线图---pyecharts

01折线图---pyecharts

Intro

可视化的整体要求为实现即可,无需关注细节,毕竟可视化只是手段。

import pyechartsfrom pyecharts.charts import Linefrom pyecharts import options as

pyecharts.__version__

'1.6.2'

pyecharts版本1.6.2

x = list(range(0, 10))y1 = [i * 2 + 1 for i in list(range(0, 10))]y2 = [i * 3 + 2 for i in list(range(0, 10))]y3 = [(i+1)/10 * 3 for i in list(range(0, 10))]

普通折线图

line1 = ( Line() .add_xaxis(xaxis_data=x) .add_yaxis("y1", y1 ,color="blue",is_symbol_show=True ,label_opts=opts.LabelOpts(is_show=False) ,markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(y=5)])# 设置水平线 ) .add_yaxis("y2", y2 ,color="red",is_symbol_show=True ,label_opts=opts.LabelOpts(is_show=False) ,symbol="triangle"#设置点的形状'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'"rect" ,markline_opts=opts.MarkLineOpts(data=[opts.MarkLineItem(y=5)]) ) .set_colors(colors=["blue","red"]) # 如果不加上这句,legends和line的颜色不一致,这个相当于全局颜色设置 .set_global_opts(title_opts=opts.TitleOpts(title="Love",pos_right="50%") # 设置标题 ,legend_opts=opts.LegendOpts(pos_right="10%",pos_top="20%",orient="vertical") # 设置图例 ,tooltip_opts =opts.TooltipOpts(trigger='axis',axis_pointer_type='cross') ,toolbox_opts =opts.ToolboxOpts(is_show=True,orient='horizontal') ,xaxis_opts =opts.AxisOpts(name="Date") ,yaxis_opts =opts.AxisOpts(name="Rate") ))line1.render_notebook()

双坐标轴折线图

line = ( Line() .add_xaxis(x) .add_yaxis("y1", y1 ,color="blue",is_symbol_show=True ,label_opts=opts.LabelOpts(is_show=False) ) .extend_axis(yaxis=opts.AxisOpts( name="y3")) .set_global_opts(title_opts=opts.TitleOpts(title="双坐标轴Demo",pos_right="50%") # 设置标题 ,legend_opts=opts.LegendOpts(pos_right="10%",pos_top="50%",orient="vertical") # 设置图例 ,tooltip_opts =opts.TooltipOpts(trigger='axis',axis_pointer_type='cross') ,toolbox_opts =opts.ToolboxOpts(is_show=True,orient='horizontal') ,xaxis_opts =opts.AxisOpts(name="X") ,yaxis_opts =opts.AxisOpts(name="Y") ))line1 = (Line() .add_xaxis(x) .add_yaxis("y3", y3 ,color="red",is_symbol_show=True ,label_opts=opts.LabelOpts(is_show=False) , yaxis_index=1))line.overlap(line1)line.render_notebook()

Ref

​​[1] http://pyecharts.org/#/zh-cn/rectangular_charts?id=line%ef%bc%9a%e6%8a%98%e7%ba%bf%e9%9d%a2%e7%a7%af%e5%9b%be​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:PythonNote033---操作Redis
下一篇:Megalo - 基于 Vue 的小程序开发框架(megalo box)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~