[Python Study Notes]餅狀圖繪制
阿新 • • 發佈:2018-03-02
usr 防止 bar .py height round style number quic
‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘‘ >>文件: 餅狀圖.py >>作者: liu yang >>郵箱: [email protected] >>博客: 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()
[Python Study Notes]餅狀圖繪制