数据可视化 pycharts实现时间数据可视化

自用版

数据格式为:

运行效果为:

python 复制代码
from pyecharts import options as opts
from pyecharts.charts import Polar, Page
import csv
filename = "./hot-dog-places.csv"
data_x = []
data_y = []
with open(filename) as f:
   reader = csv.reader(f)
   for data_row in reader:
      data_x.append(data_row)
x = data_x[0]
y1 = data_x[1]
y1 = [float(i) for i in y1]
y2 = [float(i) for i in data_x[2]]
y3 = [float(i) for i in data_x[3]]
#作第一个图
def polar1() -> Polar:
    c1 = (
        Polar(init_opts=opts.InitOpts(width="1000px", height="1000px"))
        .add_schema(radiusaxis_opts=opts.RadiusAxisOpts(data=x),
                    angleaxis_opts=opts.AngleAxisOpts(is_clockwise=True))
        .add("冠军", y1, type_="bar", stack="stack0")
        .add("亚军", y2, type_="bar", stack="stack0")
        .add("季军", y3, type_="bar", stack="stack0")
        .set_global_opts(title_opts=opts.TitleOpts(title="图例1"))
)
    return c1
#作第二个图
def polar2() -> Polar:
    c2 = (
        Polar(init_opts=opts.InitOpts(width="1000px", height="1000px"))
        .add_schema(angleaxis_opts=opts.AngleAxisOpts(data=x, is_clockwise=True))
        .add("冠军", y1, type_="bar", stack="stack0")
        .add("亚军", y2, type_="bar", stack="stack0")
        .add("季军", y3, type_="bar", stack="stack0")
        .set_global_opts(title_opts=opts.TitleOpts(title="图例2"))
)
    return c2
def creatPage():
    page = Page(layout=Page.DraggablePageLayout)
    page.add(
        polar1(),
        polar2()
    )
    page.render("时间数据可视化实验.html")

if __name__ == "__main__":
    creatPage()
相关推荐
宸津-代码粉碎机4 小时前
微服务线上踩坑复盘:接口超时、负载倾斜隐形问题根治方案(生产级配置)
java·大数据·人工智能·python·spring
速易达网络4 小时前
Python + Tkinter 实现基于 TCP/IP 的局域网聊天工具
python·信息与通信
Htojk4 小时前
电视 / 电台新闻监听平台:端到端流程技术调研
数据分析·实时音视频
多多鼠4 小时前
System Prompt 的“版本漂移”问题:从变更管理到 A/B 测试体系
开发语言·网络·人工智能·python·langchain
昔我往昔4 小时前
pytest日志问题排查记录
python·pytest
Python自动化直播4 小时前
用 Python 爬虫给 AI 直播间做数据反馈机制
人工智能·python·ai·直播
努力学习的代码小白5 小时前
源码学习04
python
Ray Wang5 小时前
Context上下文工程
python·学习·ai编程
梦影_5 小时前
Langchain简单快速上手教程(五)——聊天模型之流式传输
java·数据库·人工智能·python·langchain
ai2work6 小时前
17 · composer 进阶
python