用pyecharts在下面饼图中添加内层饼图from pyecharts.charts import Pie from pyecharts import options as opts v = ["优秀", "良好", "中等", "及格", "不及格"] c = ( Pie() .add( series_name="", data_pair=[list(z) for z in zip(v, totalseg)], radius=["30%", "75%"], center=["35%", "50%"], rosetype="area", ) .set_global_opts(title_opts=opts.TitleOpts(title="成绩分布图")) .set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{d}%")) .render("nested_pie.html") )
时间: 2023-09-11 16:13:09 浏览: 106
要在饼图中添加内层饼图,您可以使用 Pyecharts 中的 `set_series_opts` 方法,并将 `rosetype` 设置为 `'radius'`。以下是修改后的代码示例:
```python
from pyecharts.charts import Pie
from pyecharts import options as opts
v = ["优秀", "良好", "中等", "及格", "不及格"]
c = (
Pie()
.add(
series_name="",
data_pair=[list(z) for z in zip(v, totalseg)],
radius=["30%", "75%"],
center=["35%", "50%"],
rosetype="area",
)
.set_global_opts(title_opts=opts.TitleOpts(title="成绩分布图"))
.set_series_opts(
label_opts=opts.LabelOpts(formatter="{b}:{d}%"),
rosetype="radius" # 添加内层饼图
)
.render("nested_pie.html")
)
```
这样,您将在饼图中添加一个内层饼图,并将结果保存为 "nested_pie.html" 文件。请注意,我在 `set_series_opts` 中添加了 `rosetype="radius"` 来设置内层饼图的类型为 "radius"。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)