Skip to content

Commit

Permalink
Label bar plots
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-florentin-charles committed Sep 21, 2024
1 parent 8c75fc6 commit 6f4a589
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/core/utils/functions/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ def bar_column_according_to_year(yearly_rainfall: pd.DataFrame, label: Label) ->
):
return False

plt.bar(
bar_plot = plt.bar(
yearly_rainfall[Label.YEAR.value],
yearly_rainfall[label.value],
label=label.value,
)
plt.bar_label(bar_plot)

return True

Expand Down Expand Up @@ -113,7 +114,8 @@ def bar_monthly_rainfall_averages(
)
)

plt.bar(month_labels, averages, label=label)
bar_plot = plt.bar(month_labels, averages, label=label)
plt.bar_label(bar_plot)
plt.legend()

return averages
Expand Down Expand Up @@ -144,11 +146,12 @@ def bar_monthly_rainfall_linreg_slopes(
)[1]
)

plt.bar(
bar_plot = plt.bar(
month_labels,
slopes,
label=f"Linear Regression slope (mm/year) between {begin_year} and {end_year}",
)
plt.bar_label(bar_plot)
plt.legend()

return slopes
Expand Down Expand Up @@ -183,7 +186,8 @@ def bar_seasonal_rainfall_averages(
)
)

plt.bar(season_labels, averages, label=label)
bar_plot = plt.bar(season_labels, averages, label=label)
plt.bar_label(bar_plot)
plt.legend()

return averages
Expand Down Expand Up @@ -214,11 +218,12 @@ def bar_seasonal_rainfall_linreg_slopes(
)[1]
)

plt.bar(
bar_plot = plt.bar(
season_labels,
slopes,
label=f"Linear Regression slope (mm/year) between {begin_year} and {end_year}",
)
plt.bar_label(bar_plot)
plt.legend()

return slopes

0 comments on commit 6f4a589

Please sign in to comment.