表2. 中药材消费者画像数据
年龄 | 占比(%) |
20岁以下 | 2.2 |
20-30岁 | 27.9 |
31-40岁 | 56.2 |
41-50岁 | 10.9 |
51岁以上 | 2.8 |
需求二: 请基于pyecharts,用环图展示表2数据
一,导入模块
import pyecharts.options as opts
from pyecharts.charts import Pie
二,导入数据
pie=(
Pie()
.add("",[('20岁以下',2.2),('20-30岁',27.9),('31-40岁',56.2),('41-50岁',10.9),('51岁以上',2.8)],center=["40%","60%"] ,radius=[80,150])
.set_global_opts(title_opts=opts.TitleOpts(title="中药材消费者画像数据",padding=[30,300]))
)
三,绘图
pie.render_notebook()
四,运行结果