用pyecharts怎样绘制时间轮播的各种数据统计图
Admin 2022-08-05 群英技术资讯 1001 次浏览
今天就跟大家聊聊有关“用pyecharts怎样绘制时间轮播的各种数据统计图”的内容,可能很多人都不太了解,为了让大家认识和更进一步的了解,小编给大家总结了以下内容,希望这篇“用pyecharts怎样绘制时间轮播的各种数据统计图”文章能对大家有帮助。from random import randint
from pyecharts import options as opts
from pyecharts.charts import Bar, Timeline
from pyecharts.globals import ThemeType
data = {'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 tl
timeline_bar().render("timeline_bar.html")

#导入模块
from random import randint
from pyecharts import options as opts
from pyecharts.charts import Pie, Timeline
from pyecharts.globals import ThemeType
attr = ["学习", "娱乐", "休息", "运动", "交流"]
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 tl
timeline_pie1().render("timeline_pie.html")

#导入模块
from random import randint
from pyecharts import options as opts
from pyecharts.charts import Pie, Timeline
from pyecharts.globals import ThemeType
attr = ["学习", "娱乐", "休息", "运动", "交流"]
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 tl
timeline_bar1().render("玫瑰图.html")

#导入模块
from random import randint
from pyecharts import options as opts
from pyecharts.charts import Line, Timeline
from pyecharts.globals import ThemeType
list1 = [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 tl
timeline_bar().render("折线图.html")

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
Python 的元组与列表类似,不同之处在于元组的元素不能修改。元组使用小括号,列表使用方括号。元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可
这篇文章主要介绍了Python函数和文件操作详情,函数在编程中是一个很重要的角色,我们可以将若干个语句组合形成一个函数,它可以接受传入参数,并在内部进行相关计算后产生输出,下文详细内容需要的小伙伴可以参考一下
这篇文章主要介绍了Python学习之名字,作用域,名字空间,文章围绕主题展开详细内容介绍,具有一定的参考价值,需要的小伙伴可以参考以一下
这篇文章主要为大家介绍了python神经网络使用Keras构建RNN网络训练,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪<BR>
pathlib 是Python内置库,Python 文档给它的定义是 Object-oriented filesystem paths(面向对象的文件系统路径)。pathlib 提供表示文件系统路径的类,其语义适用于不同的操作系统。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008