赞
踩
一、使用Matplotlib提供的pie()函数绘制饼图:
- import matplotlib.pyplot as plt
-
- plt.figure(figsize=(10,10))
- data = [0.12,0.2341,0.4355,0.6778,0.0234,0.22,0.3341]
- labels = ['Java','Python','A','B','C','D','E']
- colors = ['red','pink','purple','orange']
-
- explode = [0,0,0.3,0,0,0,0]
-
- plt.xlim(0,12)
- plt.ylim(0,12)
-
- plt.axis(aspect = 'equal')
- plt.pie(x = data,#数据
- explode = explode,#突出显示
- labels=labels,#标签
- colors = colors,#颜色
- autopct = '%.3f%%',#百分比设置显示位数
- startangle=180,#设置饼图的初始角度
- labeldistance=1.3,#设置标签与圆心的距离
- pctdistance=0.8,#设置百分比标签与圆心的距离
- center = (6,6),#圆心的位置
- radius= 4,#设置饼图的半径
- counterclock=False,#是否为逆时针方向 False为顺时针
- wedgeprops={'linewidth':0.1,'edgecolor':'green'},#内外边界
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。