• 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()

  • 相关阅读:
    canal监听mysql实践
    如何选择最适合您需求的数据恢复工具?适用于 Windows 的 7 大数据恢复工具
    AcWing第80场周赛总结
    视频知识点(19)- YUV420好,还是YUV444好?
    7-6 Python字典-学生成绩统计
    D. Yarik and Musical Notes Codeforces Round 909 (Div. 3) 1899D
    基于jsp+mysql+ssm协同办公系统-计算机毕业设计
    文盘Rust——起手式,CLI程序
    Nacos+OpenFegin正确调用服务的姿势!
    小程序开发.微信小程序.组件.视图容器
  • 原文地址:https://blog.csdn.net/T20151470/article/details/134452038