数据可视化 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 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪4 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
Duang5 小时前
从零推导指数估值模型 —— 一个三因子打分系统的设计思路
数据分析·领域驱动设计
databook5 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田17 小时前
使用 pkgutil 实现动态插件系统
python
前端付豪21 小时前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽1 天前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战1 天前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋1 天前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者2 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python