Advertisement

Python三个饼图

阅读量:
复制代码
    import matplotlib.pyplot as plt
    
    labels = 'Comments rated 1', 'Comments rated 2', 'Comments rated 3', 'Comments rated 4', 'Comments rated 5'
    sizes = [38, 16, 18, 54, 107]
    sizes1 = [84, 45, 59, 132, 314]
    sizes2 = [205, 172, 273, 561, 1954]
    explode = (0, 0, 0, 0, 0.025)  # 设置各部分距离圆心的距离
    fig1 = plt.figure(facecolor='white',figsize=(16,8))
    ax1=plt.subplot(1,3,1)
    ax1.pie(sizes, explode=explode,autopct='%1.1f%%',
        shadow=False, startangle=90)
    ax1.axis('equal')
    ax1.legend(labels)
    
    ax1=plt.subplot(1,3,2)
    ax1.pie(sizes1, explode=expl

全部评论 (0)

还没有任何评论哟~