Skip to content

Commit

Permalink
improve plot
Browse files Browse the repository at this point in the history
  • Loading branch information
knarrff committed Feb 13, 2025
1 parent f2421ae commit c19d909
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions group_composition_plot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/*.pdf
group_composition_plot_the_fantastic_four.labels
/submissions.volume
5 changes: 3 additions & 2 deletions group_composition_plot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ all: group_composition_plot_the_fantastic_four.pdf \
group_composition_plot_the_fantastic_four.pdf: submissions/2023-12-06/Friedrich_Schiller_University_Jena_2023-12-06_10-43-44.json \
submissions/2023-12-06/Scientific_Software_Center_2023-12-21_13-13-27.json \
submissions/2023-12-06/University_of_Reading_2023-12-11_10-18-14.json \
submissions/2023-12-06/Princeton_University_2023-11-29_18-33-21.json
./group_composition_plot.py --legend --outfile $@ $^
submissions/2023-12-06/Princeton_University_2023-11-29_18-33-21.json \
group_composition_plot.py
./group_composition_plot.py --legend --outfile $@ $(filter %.json,$^)

group_composition_plot_all.pdf: $(GOOD)
./group_composition_plot.py --legend --outfile $@ $^
Expand Down
36 changes: 30 additions & 6 deletions group_composition_plot/group_composition_plot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
#!/usr/bin/env python3
import sys, argparse
import matplotlib
rc_params = {'text.usetex': True,
'svg.fonttype': 'none',
'text.latex.preamble': r'\usepackage{libertine}',
'font.size': 14,
'font.family': 'Linux Libertine',
'mathtext.fontset': 'custom',
'mathtext.rm': 'libertine',
'mathtext.it': 'libertine:italic',
'mathtext.bf': 'libertine:bold'
}
matplotlib.rcParams.update(rc_params)
import matplotlib.pyplot as plt
import json
from pprint import pprint


def errorexit(msg='internal error', code=1):
print(msg, file=sys.stderr)
sys.exit(code)
Expand Down Expand Up @@ -42,25 +55,36 @@ def errorexit(msg='internal error', code=1):
activity_to_color = {activity: colors[i] for i, activity in enumerate(activity_names)}

# Creating the joint plot
scaling = .9
scaling = 6
iymax = (len(data)+1)//2
fig = plt.figure(figsize=(scaling*16, scaling*9/2*iymax))
fig = plt.figure(figsize=(scaling, scaling/2*iymax))

i = 1
inst_names = {}
for inst, idata in data.items():
ax = fig.add_subplot(iymax, min(2, len(data)), i)
ax.pie(idata['activity_weights'], colors=colors, startangle=140, shadow=True, radius=.8)
ax.pie(idata['activity_weights'], colors=colors, startangle=90, shadow=True, radius=1)
inst_name = idata['institution_name']
if 'group_name' in idata:
inst_name = idata['group_name'] + "\n" + inst_name
inst_name = idata['group_name'] + ", " + inst_name
if not args['hide_titles']:
ax.set_title(inst_name, fontsize=20, y=-0.05)
ax.set_title(chr(ord('a')-1+i), y=-0.05)
inst_names[chr(ord('a')-1+i)] = inst_name
i += 1

# Shared legend
if args['legend']:
fig.legend(activity_names, title="Activities", loc="center right", bbox_to_anchor=(1.2, 0.5), fontsize=20)
legend = fig.legend(activity_names, title="Activities",
loc="upper right", bbox_to_anchor=(1.4, .7), frameon=False)
#nothing = matplotlib.patches.Rectangle((0,0), 1, 1, fill=False, edgecolor='none', visible=False)
#legend_inst = plt.legend([nothing]*len(inst_names),
# [i+": "+inst_name for i, inst_name in inst_names.items()],
# loc="upper left", bbox_to_anchor=(-1.2, 0.0), frameon=False)
#plt.gca().add_artist(legend_inst)
with open(args['outfile'].replace('.pdf', '.labels'), 'w') as f:
f.write(', '.join([i+": "+inst_name for i, inst_name in inst_names.items()]))

plt.tight_layout()
fig.subplots_adjust(bottom=0)
fig.savefig(args['outfile'], bbox_inches='tight')
# plt.show()
4 changes: 2 additions & 2 deletions paper.tex
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ \section{Existing Implementations}%

\begin{figure}
\centering
\includegraphics[width=\textwidth]{./group_composition_plot/group_composition_plot_the_fantastic_four.pdf}
\caption{National and international examples of RSE units and their service portfolio: Heidelberg and Princeton offer development services, whereas Jena and Reading focus mostly on teaching and consultation services.}%
\includegraphics[width=.8\textwidth]{./group_composition_plot/group_composition_plot_the_fantastic_four.pdf}
\caption{National and international examples of RSE units and their service portfolio: \input{./group_composition_plot/group_composition_plot_the_fantastic_four.labels}\unskip. Heidelberg and Princeton offer development services, whereas Jena and Reading focus mostly on teaching and consultation services.}%
\label{fig:survey}
\end{figure}

Expand Down

0 comments on commit c19d909

Please sign in to comment.