数据可视化 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()
相关推荐
倔强青铜三2 小时前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户2519162427115 小时前
Python之语言特点
python
刘立军5 小时前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机9 小时前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机10 小时前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i11 小时前
django中的FBV 和 CBV
python·django
c8i11 小时前
python中的闭包和装饰器
python
这里有鱼汤14 小时前
小白必看:QMT里的miniQMT入门教程
后端·python
TF男孩1 天前
ARQ:一款低成本的消息队列,实现每秒万级吞吐
后端·python·消息队列
该用户已不存在1 天前
Mojo vs Python vs Rust: 2025年搞AI,该学哪个?
后端·python·rust