python(添加时间轴组件):玫瑰图分月展示2020年1-3月汽车销量(pyecharts)

python(添加时间轴组件):玫瑰图分月展示2020年1-3月汽车销量(pyecharts)

转自https://zhuanlan.zhihu.com/p/144874116

案例中数据表格结构如下:

 

代码及演示:

from pyecharts import options as opts
from pyecharts.charts import Pie, Timeline
import pandas as pd
from pyecharts.globals import ThemeType

df_pie = pd.read_excel("D:\\01\\会Excel的隔壁老王\\Excel报表\\20200531-python(添加时间轴组件):玫瑰图展示2020年1-3月汽车销量\\20200531-python(添加时间轴组件):玫瑰图展示2020年1-3月汽车销量 - 副本.xlsx")


tl = Timeline(init_opts=opts.InitOpts(width="800px", height="500px",theme = ThemeType.CHALK ))
for i in ["一季度","1月","2月","3月"]:
    pie = (
        Pie(init_opts=opts.InitOpts(width="800px", height="500px",theme = ThemeType.CHALK ))
        .add(
            " ",
            df_pie[["型号",i]].values,
            rosetype="radius",
            radius=["30%", "60%"],
            center=["50%", "50%"],
            is_clockwise=1,
            label_opts=opts.LabelOpts(is_show=1),
        )
        .set_global_opts(title_opts=opts.TitleOpts("2020年{}汽车销量(微信公众号:会Excel的隔壁老王)".format(i),pos_bottom = "88%", pos_right = "17%"))
        .set_series_opts(label_opts = opts.LabelOpts(formatter="{b}:{c}\n占比:{d}%") )
    )
    tl.add(pie, "{}".format(i))

tl.add_schema(
   is_inverse = 0,
   pos_bottom = "0%"
)

tl.render_notebook()

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值