📚 简介
Pyecharts是Echarts的Python接口,用于创建交互式图表。
🚀 3D柱状图示例
import random
import os
from pyecharts import options as opts
from pyecharts.charts import Bar3D
from pyecharts.faker import Faker
current_path = os.path.dirname(os.path.abspath(__file__))
data = [(i, j, random.randint(0, 12)) for i in range(6) for j in range(24)]
file_path = os.path.join(current_path, "bar3d_base.html")
c = (
Bar3D()
.add(
"",
[[d[1], d[0], d[2]] for d in data],
xaxis3d_opts=opts.Axis3DOpts(Faker.clock, type_="category"),
yaxis3d_opts=opts.Axis3DOpts(Faker.week_en, type_="category"),
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
)
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(max_=20),
title_opts=opts.TitleOpts(title="Bar3D-基本示例"),
)
.render(file_path)
)
📦 主要特性
- ✅ 丰富的图表类型
- ✅ 交互式效果
- ✅ 支持导出HTML
- ✅ 中文文档完善