为什么我绘制的饼图没有图形显示出来?
datas = [round(result['x'][0],4),round(result['x'][1],4),round(result['x'][2],4)]
labels = ["五浪液", "茅台", "青岛啤酒"]
data_pair = [list(z) for z in zip(datas,labels)]
print(data_pair)
#[[0.0, '五浪液'], [0.6505, '茅台'], [0.3495, '青岛啤酒']]
#可视化制作上市股票行业占比饼图#
p = (
Pie(init_opts=opts.InitOpts(width="1000px", height="600px")) #初始化饼图大小
.add(
data_pair = [list(z) for z in zip(datas,labels)],
series_name = "各股票权重饼图", # 名称
radius="50%", # 饼图半径比例
center=["50%", "50%"], # 饼图中心坐标
label_opts=opts.LabelOpts(is_show=False, position="center"), # 标签位置
)
.set_global_opts(legend_opts=opts.LegendOpts(is_show=True)) # 不显示图示
.set_series_opts(
label_opts=opts.LabelOpts(formatter="{b}: {c}"),
)
.render("分配饼图.html") # 渲染文件及其名称
)