# 提取数据
v = df['continent'].values.tolist()
d = df['num'].values.tolist()
#设置颜色:
'''color_series = ['#FAE927','#E9E416','#C9DA36','#9ECB3C','#6DBC49',
'#37B44E','#3DBA78','#14ADCF','#209AC9','#1E91CA',
'#2C6BA0','#2B55A1','#2D3D8E','#44388E','#6A368B'
'#7D3990','#A63F98','#C31C88','#D52178','#D5225B',
'#D02C2A','#D44C2D','#F57A34','#FA8F2F','#D99D21',
'#CF7B25','#CF7B25','#CF7B25']
'''
# 实例化Pie类
pie1 = Pie(init_opts=opts.InitOpts(width='1350px', height='950px'))
# 设置颜色
#pie1.set_colors(color_series)
# 添加数据,设置饼图的半径,是否展示成南丁格尔图
pie1.add("", [list(z)for zin zip(v, d)],
radius=["10%", "135%"], #内半径,外半径
center=["30%", "75%"], #中心点的坐标位置
rosetype="area",
is_clockwise=False # 逆时针 or 顺时针
)
# 设置全局配置项
pie1.set_global_opts(title_opts=opts.TitleOpts(title='全球累计确诊top20'),
legend_opts=opts.LegendOpts(is_show=False),
toolbox_opts=opts.ToolboxOpts())
# 设置系列配置项
pie1.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position="inside", font_size=12,
formatter="{b}:{c}例", font_style="italic",
font_weight="bold", font_family="Microsoft YaHei"
),
)
# 生成html文档
pie1.render('南丁格尔玫瑰图.html')