Python heatmap


# input.csv example
# 5 column data file
# xcore,ycore,iteration,cost
#0,1,0,63.69
#0,2,0,63.40
#0,3,0,63.29
#0,4,0,154.62
#0,5,0,152.89
#0,6,0,154.85

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Load the CSV file into a pandas DataFrame
data = pd.read_csv('input.csv')

# Create a pivot table with the first two columns as index and columns,
# and the fourth column as values. This will be used to create the heatmap.
heatmap_data = pd.pivot_table(data, values='cost', index=['ycore'], columns=['xcore'])

colors = ['tab20', ]

for i,c in enumerate(colors):
    print(f"Colormap: {c}")
    plt.figure(i, figsize=(25, 25), dpi = 200) 
    
    # Create the heatmap using seaborn
    sns.heatmap(heatmap_data, cmap=c, annot=True, fmt=".0f")
    plt.show()