import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
# Data for the table
data = {
'Customer Segment': ['Consumer', 'Corporate', 'Home Office'],
'Observed Frequency': [5000, 2800, 1800],
'Expected Frequency': [3000, 3400, 3400],
'Difference': [2000, -600, -1600] # Change to numeric type
}
# Create a DataFrame
df = pd.DataFrame(data)
# Set the style
sns.set(style="whitegrid")
# Create a heatmap with only the numeric data
plt.figure(figsize=(8, 4)) # Adjust the size as needed
heatmap = sns.heatmap(df.iloc[:, 1:], annot=True, fmt='g', cmap='coolwarm', cbar=False, linewidths=0.5)
# Customize the plot
heatmap.set_xticklabels(df.columns[1:], fontsize=12, fontweight='bold')
heatmap.set_yticklabels(df['Customer Segment'], fontsize=12, fontweight='bold')
plt.title("Observed vs Expected Frequencies", fontsize=16)
# Show the plot
plt.show()