使用Python绘制旭日图

使用Python绘制旭日图

  • 旭日图
  • 效果
  • 代码

旭日图

旭日图是一种层次结构图表,用于展示数据的多层次关系。它类似于多层的环形图。

效果

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-W7pp1Pgn-1720511220218)(https://i-blog.csdnimg.cn/direct/9382052ea34d44079c104e67a5ee5722.png)

代码

python 复制代码
import matplotlib.pyplot as plt
from pylab import *
mpl.rcParams['font.sans-serif']=['SimHei']
# 示例数据
sizes = [15, 30, 45, 10]
labels = ['A', 'B', 'C', 'D']
sub_sizes = [7, 8, 15, 15, 20, 25, 5, 5]
sub_labels = ['A1', 'A2', 'B1', 'B2', 'C1', 'C2', 'D1', 'D2']

# 绘制旭日图
fig, ax = plt.subplots()
ax.pie(sizes, labels=labels, radius=1.3, wedgeprops=dict(width=0.3, edgecolor='w'))
ax.pie(sub_sizes, labels=sub_labels, radius=1, wedgeprops=dict(width=0.3, edgecolor='w'))
ax.set(aspect="equal")
plt.title('旭日图')
plt.show()
相关推荐
明月_清风5 小时前
Python 内存手术刀:sys.getrefcount 与引用计数的生死时速
后端·python
明月_清风5 小时前
Python 消失的内存:为什么 list=[] 是新手最容易踩的“毒苹果”?
后端·python
Flittly20 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(3)TodoWrite (待办写入)
python·agent
千寻girling1 天前
一份不可多得的 《 Django 》 零基础入门教程
后端·python·面试
databook1 天前
探索视觉的边界:用 Manim 重现有趣的知觉错觉
python·动效
明月_清风1 天前
Python 性能微观世界:列表推导式 vs for 循环
后端·python
明月_清风1 天前
Python 性能翻身仗:从 O(n) 到 O(1) 的工程实践
后端·python
helloweilei2 天前
python 抽象基类
python
用户8356290780512 天前
Python 实现 PPT 转 HTML
后端·python
zone77392 天前
004:RAG 入门-LangChain读取PDF
后端·python·面试