From 66389a6cc3d390c98eca0906cb4bfc32f5bc6e7e Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Thu, 15 Aug 2024 23:36:47 -0500 Subject: [PATCH] Use canonical colors for languages --- docs/conf.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 9f28607f..7e4adc8f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -225,13 +225,24 @@ def setup(app): try: langs = linguist(basedir) labels = [lang[0] for lang in langs] + counts = [countfiles(lang) for lang in labels] sizes = [lang[1] for lang in langs] + color_map = { + 'C': "#555555", + 'C++': "#f34b7d", + 'C#': "#178600", + 'Java': "#b07219", + 'JavaScript': "#f1e05a", + 'Python': "#3572A5", + 'Rust': "#dea584", + 'Makefile': "#427819", + } + colors = [color_map[lang] for lang in labels] _, ax = plt.subplots() - ax.pie(sizes, labels=labels, autopct='%1.1f%%', labeldistance=None, pctdistance=0.85) + ax.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', labeldistance=None, pctdistance=0.85) plt.legend(title='Languages', loc='right', bbox_to_anchor=(1,0.5), bbox_transform=plt.gcf().transFigure) plt.savefig('languages.svg', transparent=True, bbox_inches='tight') - counts = [countfiles(lang) for lang in labels] sizes = [float(size) / count for size, count in zip(sizes, counts)] pairs = sorted(zip(sizes, labels), reverse=True) labels = [lang[1] for lang in pairs] @@ -239,8 +250,9 @@ def setup(app): pos = labels.index('Makefile') labels.pop(pos) sizes.pop(pos) + colors = [color_map[lang] for lang in labels] _, ax = plt.subplots() - ax.pie(sizes, labels=labels, autopct='%1.1f%%', labeldistance=None, pctdistance=0.85) + ax.pie(sizes, labels=labels, colors=colors, autopct='%1.1f%%', labeldistance=None, pctdistance=0.85) plt.legend(title='Languages', loc='right', bbox_to_anchor=(1,0.5), bbox_transform=plt.gcf().transFigure) plt.savefig('languages-normalized.svg', transparent=True, bbox_inches='tight') except Exception: