本篇内容介绍了“怎么使用pyecharts绘制时间轮播图”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!1、pyecharts绘制时间轮播柱形
本篇内容介绍了“怎么使用pyecharts绘制时间轮播图”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
from random import randintfrom pyecharts import options as optsfrom pyecharts.charts import Bar, Timelinefrom pyecharts.globals import ThemeTypedata = {'x': ['葡萄', '芒果', '草莓', '雪梨', '西瓜', '香蕉', '橙子'], '沃尔玛': dict(zip(range(2010, 2020), [[randint(100, 1000) for fruit in range(7)] for year in range(10)])), '大润发': dict(zip(range(2010, 2020), [[randint(100, 1000) for fruit in range(7)] for year in range(10)])) }def timeline_bar() -> Timeline: x = data['x'] tl = Timeline(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) for i in range(2010, 2020): bar = ( Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) .add_xaxis(x) .add_yaxis('沃尔玛', data['沃尔玛'][i]) .add_yaxis('大润发', data['大润发'][i]) .set_global_opts(title_opts=opts.TitleOpts("{}年营业额".fORMat(i))) ) tl.add(bar, "{}年".format(i)) return tltimeline_bar().render("timeline_bar.html")
#导入模块from random import randintfrom pyecharts import options as opts from pyecharts.charts import Pie, Timelinefrom pyecharts.globals import ThemeTypeattr = ["学习", "娱乐", "休息", "运动", "交流"]list1 = [2018, 2019, 2020, 2021, 2022]list2 = [[randint(100, 1000) for time in range(7)] for year in range(5)] #嵌套列表data = {'x': attr, '时长': dict(zip(list1,list2)) }def timeline_pie1() -> Timeline: x = data['x'] tl = Timeline(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) for i in list1: c = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.WONDERLAND)) #主题风格 .add("", [list(z) for z in zip(attr,data['时长'][i])] ) .set_global_opts(title_opts=opts.TitleOpts(title="活动时长占比",pos_top="top",pos_left="left"), legend_opts=opts.LegendOpts(pos_left="right", orient="vertical")) # 设置标题 .set_series_opts(label_opts=opts.LabelOpts(formatter='{b}:{d}%'))) # 显示百分比 tl.add(c, "{}".format(i)) return tltimeline_pie1().render("timeline_pie.html")
#导入模块from random import randintfrom pyecharts import options as opts from pyecharts.charts import Pie, Timelinefrom pyecharts.globals import ThemeTypeattr = ["学习", "娱乐", "休息", "运动", "交流"]list1 = [2018, 2019, 2020, 2021, 2022]list2 = [[randint(100, 1000) for time in range(7)] for year in range(5)] #嵌套列表data = {'x': attr, '时长': dict(zip(list1, list2)) }def timeline_bar1() -> Timeline: x = data['x'] tl = Timeline(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) for i in list1: c = ( Pie(init_opts=opts.InitOpts(theme=ThemeType.LIGHT)) #主题风格 .add("", [list(z) for z in zip(attr,data['时长'][i])],radius=["25%", "75%"],rosetype="radius") .set_global_opts(title_opts=opts.TitleOpts(title="活动时长占比",pos_top="top",pos_left="left"), legend_opts=opts.LegendOpts(pos_left="right", orient="vertical")) # 设置标题 .set_series_opts(label_opts=opts.LabelOpts(formatter='{b}:{d}%'))) # 显示百分比 tl.add(c, "{}".format(i)) return tltimeline_bar1().render("玫瑰图.html")
#导入模块from random import randintfrom pyecharts import options as opts from pyecharts.charts import Line, Timelinefrom pyecharts.globals import ThemeTypelist1 = [2018, 2019, 2020, 2021, 2022]list2 = [[randint(100, 1000) for time in range(7)] for year in range(5)] #嵌套列表data = {'x': ['学习','娱乐','休息','运动','交流'], '时长': dict(zip(list1, list2)) }def timeline_bar() -> Timeline: x = data['x'] tl = Timeline() for i in list1: bar = ( Line() .add_xaxis(x) .add_yaxis('时长(min)', data['时长'][i]) .set_global_opts(title_opts=opts.TitleOpts("{}年活动时长统计".format(i))) ) tl.add(bar, "{}年".format(i)) # tl.add_schema(play_interval=1200, #播放速度 # is_timeline_show=False, #是否显示 timeline 组件 # is_auto_play=True) return tltimeline_bar().render("折线图.html")
“怎么使用pyecharts绘制时间轮播图”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!
--结束END--
本文标题: 怎么使用pyecharts绘制时间轮播图
本文链接: https://lsjlt.com/news/342334.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0