温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么使用pyecharts绘制时间轮播图

发布时间:2022-06-30 11:50:28 阅读:326 作者:iii 栏目:开发技术
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

本篇内容介绍了“怎么使用pyecharts绘制时间轮播图”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

1、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(20102020), [[randint(1001000for fruit in range(7)] for year in range(10)])),
        '大润发'dict(zip(range(20102020), [[randint(1001000for 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(20102020):
        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")

怎么使用pyecharts绘制时间轮播图

2、pyecharts绘制时间轮播饼图

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

怎么使用pyecharts绘制时间轮播图

3、pyecharts绘制时间轮播玫瑰图

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

怎么使用pyecharts绘制时间轮播图

4、pyecharts绘制时间轮播折线图

#导入模块
from random import randint
from pyecharts import options as opts       
from pyecharts.charts import Line, Timeline
from pyecharts.globals import ThemeType
list1 = [20182019202020212022]
list2 = [[randint(1001000for 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")

怎么使用pyecharts绘制时间轮播图

“怎么使用pyecharts绘制时间轮播图”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×