Py学习  »  Python

python 饼状图 文字重叠问题

小文 • 5 年前 • 361 次点击  

我是新手,今天用python 画了饼状图,出现的标题重叠问题

代码数据

 labels = [u'headBlock\n', u'LeftBlock\n', u'RightBlock\n', u'OtherBlock\n']
        fracs = [count_dict[1] / cnumber * 100, count_dict[2] / cnumber * 100, count_dict[3] / cnumber * 100,
                 (cnumber - count_dict[1] - count_dict[2] - count_dict[3]) / cnumber * 100]

        explode = [x * 0.01 for x in range(4)]  # 与labels一一对应,数值越大离中心区越远
        plt.axes(aspect=1)  # set this , Figure is round, otherwise it is an ellipse
        # autopct ,show percet
        plt.pie(x=fracs, labels=labels, explode=explode, autopct='%3.1f %%',
                shadow=True, labeldistance=1.1, startangle=90, pctdistance=0.6

                )
        #plt.legend(loc=7, bbox_to_anchor=(1.2, 0.80), ncol=3, fancybox=True, shadow=True, fontsize=8)
        plt.title(titlename)

输出图片格式

跪求大神们的解决办法

最后一次修改于 (2018-10-15 16:48)
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/25066
 
361 次点击