Advertisement

在Python的matplotlib中使用饼图

阅读量:

饼图

  • 配置色彩参数
    • 调整文字色彩
    • 编辑说明性文字
复制代码
    %matplotlib inline
    import matplotlib.pyplot as plt
    
    m = 51212
    f = 40742
    m_perc = m/(m+f)
    f_perc = f/(m+f)
    
    colors = ['navy','lightcoral']
    labels = ["Male","Female"]
    
    plt.figure(figsize=(8,8))
    paches,texts,autotexts = plt.pie([m_perc, f_perc], labels = labels,
    				autopct = '%1.1f%%', explode = [0,0.05], colors = colors)
    
    for text in texts+autotexts:
    text.set_fontsize(20)
    for text in autotexts:
    text.set_color('white')
    
    
      
      
      
      
      
      

全部评论 (0)

还没有任何评论哟~