Fix small bugs in plot generation.

This commit is contained in:
Sebastian Lenzlinger 2024-01-08 16:00:26 +01:00
parent 06e3897b9c
commit 1360ba04dc

View File

@ -20,7 +20,7 @@ def plt_acc_by_year(db):
result = db.execute_query(acc_year_sql)
result_df = pd.DataFrame(result)
fig = px.bar(result_df, y='year', x='count', orientation='h', title='No. of Accidents per Year')
fig = px.bar(result_df, y='year', x='count', orientation='h', title='Total Accidents per Year')
fig.write_image("fig/acc_by_year.png")
fig.write_html("html/acc_by_year.html")
@ -67,11 +67,11 @@ def plt_acc_by_day_year(db):
df,
x='weekday',
y='count',
title='Accidents by Weekday',
title='Accidents by Weekday over the Years',
animation_frame='year',
labels={'weekday': 'Weekday', 'count': 'Number of Accidents'},
category_orders={'weekday': ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']},
orientation='h'
orientation='v'
)
fig.update_yaxes(range=[0, 1000])
# Customize the layout to include a slider
@ -136,7 +136,7 @@ def plt_acc_by_daytime(db):
result = db.execute_query(acc_weekday_sql)
result_df = pd.DataFrame(result)
fig = px.bar(result_df, y='hour', x='count', orientation='h', title='Accidents by day')
fig = px.bar(result_df, y='hour', x='count', orientation='h', title='Accidents by hour')
fig.write_image("fig/acc_by_daytime.png")
fig.write_html("html/acc_by_daytime.html")