Sort pie chart values
This commit is contained in:
parent
916ba0ab42
commit
4f001c885e
1 changed files with 12 additions and 0 deletions
|
@ -57,6 +57,18 @@ class QuoteQuota(commands.Cog):
|
||||||
# And now filter out any -1% counts
|
# And now filter out any -1% counts
|
||||||
counts = [c for c in counts if c != -1]
|
counts = [c for c in counts if c != -1]
|
||||||
|
|
||||||
|
mapping = {}
|
||||||
|
for i, author in enumerate(usernames):
|
||||||
|
mapping[author] = counts[i]
|
||||||
|
|
||||||
|
# Sort the authors by count
|
||||||
|
new_mapping = {}
|
||||||
|
for author, count in sorted(mapping.items(), key=lambda x: x[1], reverse=True):
|
||||||
|
new_mapping[author] = count
|
||||||
|
|
||||||
|
usernames = list(new_mapping.keys())
|
||||||
|
counts = list(new_mapping.values())
|
||||||
|
|
||||||
fig, ax = plt.subplots(figsize=(7, 7))
|
fig, ax = plt.subplots(figsize=(7, 7))
|
||||||
ax.pie(
|
ax.pie(
|
||||||
counts,
|
counts,
|
||||||
|
|
Loading…
Reference in a new issue