pyecharts------组合图表
作者:互联网
一、Timeline-时间轴
1、代码
点击查看代码
import datetime
begin = datetime.date(2022, 7, 23)
end = datetime.date(2022, 7, 29)
cate = ['Apple', 'Huawei', 'MI', 'Oppo', 'Vivo', 'Samsung']
tl = Timeline()
tl.add_schema()
for i in range((end - begin).days + 1):
day = begin + datetime.timedelta(days=i)
bar = (Bar().add_xaxis(cate).add_yaxis(
'电商渠道',
(lambda n: [random.randint(100, 200) for _ in range(n)])(len(cate))))
tl.add(bar, day)
tl.render_notebook()
2、效果图
二、Tab-时间轴
1、代码
点击查看代码
begin = datetime.date(2022, 7, 23)
end = datetime.date(2022, 7, 29)
cate = ['Apple', 'Huawei', 'MI', 'Oppo', 'Vivo', 'Samsung']
date_list = [
str(begin + datetime.timedelta(days=i)) for i in range((end - begin).days + 1)
]
tab = Tab()
for i in cate:
line = (
Line()
.add_xaxis(date_list)
.add_yaxis('', (lambda n : [random.randint(0, 100) for _ in range(n)])(len(date_list)))
)
tab.add(line, i)
tab.render_notebook()
2、效果图
三、顺序多图
1、代码
点击查看代码
x_data = ['Apple', 'Huawei', 'Xiaomi', 'Oppo', 'Vivo', 'Meizu']
y_data = [123, 153, 89, 107, 98, 23]
bar = (
Bar()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
line = (
Line()
.add_xaxis(x_data)
.add_yaxis('', y_data)
)
page = Page()
page.add(bar, line)
page.render_notebook()
2、效果图
标签:begin,pyecharts,cate,datetime,图表,date,add,------,data 来源: https://www.cnblogs.com/bite-an-orange/p/16512260.html