2.141
This commit is contained in:
parent
4e414dce2b
commit
33677fbadf
BIN
archive/2026/ESAW2026/images/ratings[total][type=pie].png
Executable file
BIN
archive/2026/ESAW2026/images/ratings[total][type=pie].png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
57
chart.py
57
chart.py
@ -16,7 +16,7 @@ import matplotlib.pyplot as Plot
|
||||
import matplotlib.patches as patches
|
||||
|
||||
# consts
|
||||
TITLE = "AGDQ 2026"
|
||||
TITLE = "ESA Winter 2026"
|
||||
USE_LEGEND = False # display the legend with markers
|
||||
TITLE_OFFSET = 0 # 2.5 # to-do: dynamically set this to how many columns are set with legend
|
||||
|
||||
@ -748,6 +748,53 @@ def plot_sub_bars(sub, stats):
|
||||
sub.tick_params(axis="y", left=False, labelleft=False)
|
||||
sub.tick_params(axis="x", bottom=True, top=True, labelbottom=True, labeltop=True)
|
||||
|
||||
def plot_sub_pie(sub, stats):
|
||||
total_buckets = [0] * 10
|
||||
for stat in stats:
|
||||
if stat is None: continue
|
||||
for i in range(len(stat['buckets'])):
|
||||
total_buckets[i] += stat['buckets'][i]
|
||||
|
||||
bucket_config = [
|
||||
(4, "F", "#73172d"),
|
||||
(5, "D", "#df3e23"),
|
||||
(6, "C", "#f9a31b"),
|
||||
(7, "B", "#fffc40"),
|
||||
(8, "A", "#9cdb43"),
|
||||
(9, "S", "#20d6c7"),
|
||||
]
|
||||
|
||||
labels = []
|
||||
sizes = []
|
||||
colors = []
|
||||
|
||||
for i, label, color in bucket_config:
|
||||
if total_buckets[i] > 0:
|
||||
labels.append(label)
|
||||
sizes.append(total_buckets[i])
|
||||
colors.append(color)
|
||||
|
||||
if not sizes:
|
||||
sub.text(0.5, 0.5, "No Data", ha="center", va="center")
|
||||
return
|
||||
|
||||
wedges, texts, autotexts = sub.pie(
|
||||
sizes,
|
||||
labels=labels,
|
||||
colors=colors,
|
||||
autopct='%1.1f%%',
|
||||
startangle=140,
|
||||
radius=2,
|
||||
pctdistance=0.75,
|
||||
textprops={'color': COLORS["TEXT"]}
|
||||
)
|
||||
|
||||
for autotext in autotexts:
|
||||
autotext.set_color('black')
|
||||
autotext.set_weight('bold')
|
||||
|
||||
sub.set_aspect('equal')
|
||||
|
||||
def create_plot( stats ):
|
||||
# determine dimensions
|
||||
cols = max(MIN_COLUMNS, min(5, round(math.sqrt(len(stats) / 6))))
|
||||
@ -759,7 +806,11 @@ def create_plot( stats ):
|
||||
subs = [subs]
|
||||
|
||||
# set main figure stuff
|
||||
figSize = (cols * COL_WIDTH + 1, rows * ROW_HEIGHT + 1.5)
|
||||
if MODE == "pie":
|
||||
figSize = (cols * COL_WIDTH + 1, rows * 4 + 1.5)
|
||||
else:
|
||||
figSize = (cols * COL_WIDTH + 1, rows * ROW_HEIGHT + 1.5)
|
||||
|
||||
fig.set_size_inches(figSize)
|
||||
fig.set_tight_layout(True)
|
||||
|
||||
@ -823,6 +874,8 @@ def create_plot( stats ):
|
||||
plot_sub_bars(sub, stats_sub)
|
||||
elif MODE == "boxplot":
|
||||
plot_sub_boxplot(sub, stats_sub)
|
||||
elif MODE == "pie":
|
||||
plot_sub_pie(sub, stats_sub)
|
||||
|
||||
# Stats related
|
||||
def compute_mean_smart(ratings):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user