1

i tried this code to create multiple pie chart on multi groups:

fig, axs = plt.subplots(4, 2, figsize=(25, 30), subplot_kw={'aspect':'equal'})
colors = ['#ff9999','#66b3ff','#99ff99','#ffcc99']
explode = (0.06,0.06,0.06,0.06)


for i, (groupname, subdf) in enumerate(df_mitigation.groupby('account_name')):
    ax = axs[i // 2, i % 2]
    ax.pie(subdf.cnt,labels=subdf.actual_mitigation_action, shadow=True, 
    autopct='%1.1f%%',radius=1,wedgeprops=dict(width=0.9), 
    explode=[0.05] * len(subdf.cnt),counterclock=True, startangle=20,
    pctdistance=0.5, labeldistance=1.1)
    ax.set_title(groupname,fontweight="bold")
    plt.subplots_adjust(left=0.0, bottom=0.1, right=0.86)

some pie are good and some overlapping the legend. as shown in the screenshot.enter image description here

meitale
  • 137
  • 4
  • 15
  • [This answer from 2017](https://stackoverflow.com/a/43281595/11789440) might help you set up a legend that lies to the side – thshea Dec 06 '20 at 19:17

0 Answers0