数据可视化 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()
相关推荐
墨染天姬5 小时前
【人工智能训练师】python语法二
开发语言·人工智能·python
卷毛迷你猪6 小时前
快速实验篇(B17)B组实验总结报告:电商用户行为数据分析的完整实践
数据挖掘·数据分析
ikun_文7 小时前
Python高级特性
python
用户872185012437 小时前
港股投资者必备:三大数据源对比,哪种最适合实时行情与回测?
python
溪语流沙7 小时前
【Web全栈进阶】Alembic数据库迁移:改表结构不再删库
前端·数据库·python·elasticsearch·postgresql
Evan_Lai7 小时前
(一)独热编码、标签编码、目标编码、序数编码详解
python·机器学习
用户7624117567057 小时前
第二章 Python语言基础
python
129Lab8 小时前
BMS 核心算法:SOC 估算从安时积分到 LSTM-UKF 串级融合的 30 年演进(附 Python 实现)
python·算法·lstm·python3.11·bms·soc估算
129Lab8 小时前
电池热管理仿真的AI加速:用Python+PINN物理信息神经网络替代传统CFD的可行性探索
pytorch·python·cfd·pinn·物理信息神经网络·仿真加速·电池热管理
用户298698530148 小时前
Python 中 HTML 转 PDF 的实现方法
python·html·api