• python科研绘图:圆环图


    圆环图是一种特殊的图形,它可以显示各个部分与整体之间的关系。圆环图由两个或多个大小不一的饼图叠加而成,中间被挖空,看起来像一个甜甜圈。因此,圆环图也被称为“甜甜圈”图。

    与饼图相比,圆环图的空间利用率更高,可以对比多组不同的数据。在圆环图中,数据源自数据表的行或列,排列在工作表的列或行中。它不仅能对比一组数据,还能对比多组不同的数据,更能突出地显示数据的分布情况。

    此外,圆环图还可以显示文本信息,标题等。在圆环图中,中间空心的部分可以用来展示数据的总数,用圆环的弧长和颜色表示不同数据的占比,图表旁边有图例用来解释说明。

    1. import matplotlib.pyplot as plt
    2. # Setting labels for items in Chart
    3. Employee = ['Roshni', 'Shyam', 'Priyanshi',
    4. 'Harshit', 'Anmol']
    5. # Setting size in Chart based on
    6. # given values
    7. Salary = [40000, 50000, 70000, 54000, 44000]
    8. # colors
    9. colors = ['#FF0000', '#0000FF', '#FFFF00',
    10. '#ADFF2F', '#FFA500']
    11. # explosion
    12. explode = (0.05, 0.05, 0.05, 0.05, 0.05)
    13. # Pie Chart
    14. plt.pie(Salary, colors=colors, labels=Employee,
    15. autopct='%1.1f%%', pctdistance=0.85,
    16. explode=explode)
    17. # draw circle
    18. centre_circle = plt.Circle((0, 0), 0.70, fc='white')
    19. fig = plt.gcf()
    20. # Adding Circle in Pie chart
    21. fig.gca().add_artist(centre_circle)
    22. # Adding Title of chart
    23. plt.title('Employee Salary Details')
    24. # Displaing Chart
    25. plt.show()

    1. import matplotlib.pyplot as plt
    2. # 数据
    3. labels = ['Label1', 'Label2', 'Label3', 'Label4']
    4. sizes = [15, 30, 45, 10]
    5. colors = ['gold', 'yellowgreen', 'lightcoral', 'lightskyblue']
    6. # 绘图
    7. fig1, ax1 = plt.subplots()
    8. ax1.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', startangle=90)
    9. ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
    10. # Draw a white circle at the center
    11. centre_circle = plt.Circle((0, 0), 0.70, fc='white')
    12. fig = plt.gcf()
    13. fig.gca().add_artist(centre_circle)
    14. plt.show()

  • 相关阅读:
    使用Python进行网站页面开发——Django快速入门
    Android-S Emulator
    基于 eBPF 的 Kubernetes 可观测实践
    就以下数据怎么写代码弄成可视化数据,
    Tensorflow基础 Tensorflow基本操作(三)
    PPT 批量删除每页相同位置的内容
    有效利用云测试的关键要素是什么
    Springboot中国古代史在线学习网站 毕业设计-附源码260839
    linux学习:视频输入+V4L2
    2-1两数之和
  • 原文地址:https://blog.csdn.net/T20151470/article/details/134452038