forked from UoB-HPC/miniBUDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heatmap.py
35 lines (23 loc) · 1.03 KB
/
heatmap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import copy
import matplotlib
def linear_scale(old_min, old_max, new_min, new_max, old_value):
return ((old_value - old_min) / (old_max - old_min)) * (new_max - new_min) + new_min
pd.set_option('display.max_columns', None)
data = pd.read_csv('heatmap.csv', sep=',', comment='#', skiprows=1)[["ppwi", "wgsize", "sum_ms"]]
# data.sort_values(by=['ppwi'], ascending=False)
normalised = data.copy()
normalised["sum_ms"] = normalised["sum_ms"].apply(
lambda x: linear_scale(normalised["sum_ms"].min(), normalised["sum_ms"].max(), 0, 100, x) )
out = normalised.pivot(index="ppwi", columns="wgsize", values="sum_ms")
out.sort_index(level=0, ascending=False, inplace=True)
# data = np.genfromtxt('heatmap.csv', delimiter=',')
print(out)
my_cmap = copy.copy(matplotlib.cm.get_cmap('rocket')) # copy the default cmap
my_cmap.set_bad((0,0,0))
sns.heatmap(out, annot=True, norm=LogNorm(), cmap=my_cmap)
plt.show()