Skip to content

Commit

Permalink
plot for BV analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulineTL committed Dec 18, 2024
1 parent acf1216 commit 2f5bbe1
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/scripts/plot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import geopandas as gpd
import matplotlib.pyplot as plt
import matplotlib.lines as mlines
import seaborn as sns

def plot_highest_rated_styles_by_season(highest_rated_style):
"""
Expand Down Expand Up @@ -85,3 +86,40 @@ def plot_high_low_abv_trends(high_abv, low_abv):

plt.tight_layout()
plt.show()


def plot_abv_seasonal_trends(data, metric):
"""
Plots seasonal trends of beer ratings for low and high ABV categories across regions
Parameters:
- data: The dataset containing the ratings
- metric: The column name representing the metric to plot
"""

grouped_data = data.groupby(['season', 'region', 'abv_category'])[metric].mean().reset_index()

plt.figure(figsize=(10, 5))

# Low ABV
plt.subplot(1, 2, 1)
low_abv_data = grouped_data[grouped_data['abv_category'] == 'low']
sns.lineplot(data=low_abv_data, x='season', y=metric, hue='region', style='region', markers=True, dashes=False)
plt.xlabel('Season')
plt.ylabel(metric.capitalize())
plt.title("Low ABV beers")
plt.xticks(rotation=45)
plt.legend(title='Region', loc='upper left', bbox_to_anchor=(1, 1))

# High ABV
plt.subplot(1, 2, 2)
high_abv_data = grouped_data[grouped_data['abv_category'] == 'high']
sns.lineplot(data=high_abv_data, x='season', y=metric, hue='region', style='region', markers=True, dashes=False)
plt.xlabel('Season')
plt.ylabel(metric.capitalize())
plt.title("High ABV beers")
plt.xticks(rotation=45)
plt.legend(title='Region', loc='upper left', bbox_to_anchor=(1, 1))

plt.tight_layout()
plt.show()

0 comments on commit 2f5bbe1

Please sign in to comment.