pyecharts热力图
时间: 2023-11-22 08:47:58 浏览: 204
以下是使用pyecharts绘制热力图的示例代码和效果图:
```python
from pyecharts import options as opts
from pyecharts.charts import HeatMap
# 构造数据
data = [
[0, 0, 5],
[0, 1, 1],
[0, 2, 0],
[0, 3, 0],
[0, 4, 0],
[0, 5, 0],
[0, 6, 0],
[0, 7, 0],
[0, 8, 0],
[0, 9, 0],
[0, 10, 0],
[0, 11, 2],
[0, 12, 4],
[0, 13, 1],
[0, 14, 1],
[0, 15, 3],
[0, 16, 4],
[0, 17, 6],
[0, 18, 4],
[0, 19, 4],
[0, 20, 3],
[0, 21, 3],
[0, 22, 2],
[0, 23, 5],
[1, 0, 7],
[1, 1, 0],
[1, 2, 0],
[1, 3, 0],
[1, 4, 0],
[1, 5, 0],
# ...省略部分数据
]
# 绘制热力图
heatmap = (
HeatMap()
.add_xaxis(["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"])
.add_yaxis("Series 1", ["Morning", "Afternoon", "Evening"], data)
.set_global_opts(
title_opts=opts.TitleOpts(title="HeatMap-基本示例"),
visualmap_opts=opts.VisualMapOpts(),
)
)
# 展示图表
heatmap.render("heatmap.html")
```
效果图如下:
![pyecharts热力图示例效果图](https://cdn.jsdelivr.net/gh/katzeilla/picbed/img/20211014163408.png)
阅读全文