[Python Study Notes]饼状图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' >>文件: 饼状图.py >>作者: liu yang >>邮箱: liuyang0001@outlook.com >>博客: www.cnblogs.com/liu66blog ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' #!/usr/bin/env python # -*- coding: utf-8 -*- import matplotlib import matplotlib.pyplot as plt # 定义要使用的字体,防止出现中文乱码 font=matplotlib.font_manager.FontProperties(fname=r"C:\Windows\Fonts\Deng.ttf") # pie chart饼状图 def pie_chart(): # 为每个区域添加标签 labels=['A','B','C','D'] # 每块区域的数据 fracs=[15,30,45,10] #使x y轴比例相同 plt.axes(aspect=1) # 突出某一部分区域 explode=[0,0.05,0,0] #autopct显示百分比 plt.pie(x=fracs,labels=labels,autopct='%.0f%%',explode=explode) plt.title('饼状图',fontproperties=font) # 显示 plt.show() if __name__ == '__main__': pie=pie_chart()
最有用的语言,除了English,其次可能是Python