import pandas as pd
import matplotlib.pyplot as plt

# Read the CSV file
df = pd.read_csv('../sample_of_interest/relevant_commits.csv')

# get conts for each value of df["Tag"]

# Get counts for each value of df["Tag"]
tag_counts = df["Tag"].value_counts()

# Extract the tags and their counts
tags = tag_counts.index

tags = tags.tolist()

tags[4] = "Unchecked return values\n for low level calls"

counts = tag_counts.values

# Plotting
plt.figure(figsize=(16, 9))
bars = plt.bar(tags, counts, color='skyblue', width=0.5)

# Add count labels on top of each bar
for bar, count in zip(bars, counts):
    plt.text(bar.get_x() + bar.get_width() / 2, bar.get_height(),
             f'{count}', ha='center', va='bottom', fontsize=14)

plt.ylabel('Counts', fontsize=14)
plt.title('Counts by Category', fontsize=14)
plt.xticks(rotation=45, ha='right', fontsize=14)
plt.tight_layout()
plt.savefig("vulnerability_distribution.png")
