数据可视化 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()
相关推荐
江沉晚呤时8 小时前
在 C# 中调用 Python 脚本:实现跨语言功能集成
python·microsoft·c#·.net·.netcore·.net core
电脑能手9 小时前
如何远程访问在WSL运行的Jupyter Notebook
ide·python·jupyter
Edward-tan9 小时前
CCPD 车牌数据集提取标注,并转为标准 YOLO 格式
python
老胖闲聊10 小时前
Python I/O 库【输入输出】全面详解
开发语言·python
倔强青铜三10 小时前
苦练Python第18天:Python异常处理锦囊
人工智能·python·面试
倔强青铜三10 小时前
苦练Python第17天:你必须掌握的Python内置函数
人工智能·python·面试
迷路爸爸18010 小时前
让 VSCode 调试器像 PyCharm 一样显示 Tensor Shape、变量形状、变量长度、维度信息
ide·vscode·python·pycharm·debug·调试
咸鱼鲸11 小时前
【PyTorch】PyTorch中的数据预处理操作
人工智能·pytorch·python
Dxy123931021611 小时前
Python ExcelWriter详解:从基础到高级的完整指南
开发语言·python
金玉满堂@bj12 小时前
Conda 安装包的用途
python