-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyHeatmapInPython.py
More file actions
47 lines (39 loc) · 1.38 KB
/
Copy pathmyHeatmapInPython.py
File metadata and controls
47 lines (39 loc) · 1.38 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Read CSV file
# this for the rows and columns
data = pd.read_csv("heatmap_dataset_1.csv", sep=";", decimal=',')
# this is for the data as float (else String making problems)
data2 = pd.read_csv("heatmap_dataset_1.csv", sep=";", index_col=0, decimal=',')
# Define row and column labels
header = data.columns[1:].tolist() # only first column
header.reverse() # reverse it bcs I want to have M1 and M1 both on the bottom left to start
print(header)
index = data.iloc[:, 0].tolist() # only first row
print(index)
# create sample matrix reverse it bcs I want to have M1 and M1 both on the bottom left to start
sample_matrix = data2.values.astype(float)[::-1]
print(sample_matrix)
#cmap farben:
# jet
# viridis
# inferno
# magma
# plasma
# Create heatmap
# cmap = color name + s
# annot = Values in the fields to be shown or not
# fmt = shows 1 decimal places (in detail is the format Type of the String)
# cbar = corrulation bar
# xticklabels = xField
# yticklabels = yField
sns.heatmap(sample_matrix, cmap="jet", annot=True, fmt=".1f", cbar=True, xticklabels=index, yticklabels=header, linewidths=0.5, linecolor="yellow")
# Set axis labels and title
plt.xlabel("Columns")
plt.ylabel("Rows")
plt.title("Heatmap Correlation")
# Adjust bottom and top spacing
plt.subplots_adjust(bottom=0.18, top=0.9)
# Show the plot
plt.show()