matplotlib之饼状图

import numpy as np
import matplotlib.pylab as mp

values = [26, 17, 21, 29, 11]
spaces = [0.05, 0.01, 0.01, 0.01, 0.01]
labels = ['Python', 'JavaScript', 'C++', 'Java', 'PHP']
colors = ['dodgerblue', 'orangered', 'limegreen', 'violet', 'gold']

mp.figure('Pie', facecolor='lightgray')
mp.axis('equal')
mp.pie(
    values,
    spaces,
    labels,
    colors,
    "%.2f%%",
    shadow=True,
    startangle=0,
    radius=1

)
mp.legend(loc=1)
mp.show()

posted @ 2019-08-09 10:49  一如年少模样  阅读(398)  评论(0编辑  收藏  举报