python可视化---内嵌环形饼图
Posted 车路历程
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python可视化---内嵌环形饼图相关的知识,希望对你有一定的参考价值。
import matplotlib.pyplot as plt import matplotlib as mpl mpl.rcParams["font.sans-serif"] = ["SimHei"] mpl.rcParams["axes.unicode_minus"] = False elements = ["面粉", "砂糖", "奶油", "草莓酱", "坚果"] weight1 = [40, 15, 20, 10, 15] weight2 = [30, 25, 20, 15, 10] colormapList = ["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00"] outer_colors = colormapList inner_colors = colormapList wedges1, texts1, autotexts1 = plt.pie(weight1, autopct="%3.1f%%", radius = 1, pctdistance=0.85, colors=outer_colors, textprops=dict(color="w"), wedgeprops=dict(width=0.3, edgecolor="w")) wedges2, texts2, autotexts2 = plt.pie(weight2, autopct="%3.1f%%", radius = 0.7, pctdistance=0.75, colors=outer_colors, textprops=dict(color="w"), wedgeprops=dict(width=0.3, edgecolor="w")) plt.legend(wedges1, elements, fontsize=12, title="配料图", loc="center left", bbox_to_anchor=(0.91, 0, 0.3, 1)) plt.setp(autotexts1, size=15, weight="bold") plt.setp(autotexts2, size=15, weight="bold") plt.setp(texts1, size=12) plt.title("不同果酱面包配料比例表的比较") plt.show()
以上是关于python可视化---内嵌环形饼图的主要内容,如果未能解决你的问题,请参考以下文章
tableau可视化函数使用案例(六十七)-Tableau饼图及其变种(环形图南丁格尔玫瑰图旭日图)