made graph more pretty

This commit is contained in:
2023-11-28 01:30:24 +01:00
parent 08eeb5c78b
commit 836e81d566

View File

@@ -12,6 +12,7 @@ content = BeautifulSoup(page.read().decode(), 'html.parser')
teams = content.find_all("a", class_="link-underline link-underline-opacity-0 link-underline-opacity-100-hover", title=True) teams = content.find_all("a", class_="link-underline link-underline-opacity-0 link-underline-opacity-100-hover", title=True)
names = [team.get_text() for team in teams] names = [team.get_text() for team in teams]
times_with_points = [team['title'] for team in teams] times_with_points = [team['title'] for team in teams]
# convert times to hours
times = [parse(time_with_points.split('/')[0].strip()) / 3600 for time_with_points in times_with_points] times = [parse(time_with_points.split('/')[0].strip()) / 3600 for time_with_points in times_with_points]
points = [int(time_with_points.split('/')[1].strip()) for time_with_points in times_with_points] points = [int(time_with_points.split('/')[1].strip()) for time_with_points in times_with_points]
# filter out teams with no time entry # filter out teams with no time entry
@@ -22,10 +23,15 @@ names = names[0:len(times)]
fig, ax = plt.subplots() fig, ax = plt.subplots()
ax.plot(names, times, 'o-', label='Binex Times') ax.plot(names, times, 'o-', label='Binex Times')
ax.set_ylabel('Total time taken in hours')
ax.set_xlabel('Team name')
# Annotate each data point with its x-axis value # Annotate each data point with its x-axis value
for x, y in zip(names, times): for x, y in zip(names, times):
ax.annotate(f'{x}', (x, y), textcoords="offset points", xytext=(0,10), ha='center') ax.annotate(f'{x}', (x, y), textcoords="offset points", xytext=(0,10), ha='center')
# Hide xticks
ax.set_xticks([])
ax.legend() ax.legend()
plt.show() plt.show()