countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

commit 972f1d726d7465d31482db9f1cb53bbd30497f50
parent e5286c020ef4149826a1047b824fb26d76ef9f12
Author: ashermorgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Fri, 23 Apr 2021 12:55:46 -0700

Add legend to contributors pie chart

Diffstat:
Mbot.py | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bot.py b/bot.py @@ -736,7 +736,10 @@ async def contributors(ctx, option=""): # Add data to graph x = [x["author"] for x in contributors] y = [x["contributions"] for x in contributors] - ax.pie(y, labels=[await getUsername(i) for i in x], autopct="%1.1f%%", startangle = 90) + pieData = ax.pie(y, autopct="%1.1f%%", startangle=90) + + # Add legend + ax.legend(pieData[0], [await getUsername(i) for i in x[:min(len(x), 15)]], bbox_to_anchor=(1,1.025), loc="upper left") # Save graph fig.savefig(tmp.name, bbox_inches="tight", pad_inches=0.2)