首页 > 其他 > 详细

绘制饼状图

时间:2020-04-07 01:41:33      阅读:69      评论:0      收藏:0      [点我收藏+]
 1 import matplotlib.pyplot as plt 
 2 import numpy as np 
 3 #准备女生的人数及比例
 4 man = 71351
 5 women = 68187
 6 man_perc = man/(women+man)
 7 women_perc = women/(women+man)
 8 #添加名称
 9 labels = [,]
10 #添加颜色
11 colors = [blue,red]
12 #绘制饼状图 pie
13 paches,texts,autotexts = plt.pie([man_perc,women_perc],labels=labels,colors=colors,explode=(0,0.05),autopct=%0.1f%%)
14 # labels 名称, colors 颜色, explode 分裂, autopct 显示百分比
15 plt.rcParams[font.sans-serif]=[SimHei] #用来正常显示中文标签 
16 #设置饼状图中的字体颜色
17 for text in autotexts:
18     text.set_color(white)
19 #设置字体大小
20 for text in texts+autotexts:
21     text.set_fontsize(20)
22 plt.show() 

技术分享图片

 

 

 

绘制饼状图

原文:https://www.cnblogs.com/monsterhy123/p/12650236.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!