-
Notifications
You must be signed in to change notification settings - Fork 0
/
heatmap_plot.py
38 lines (30 loc) · 972 Bytes
/
heatmap_plot.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
36
37
38
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
#fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(6.2, 5.1))
fig, axes = plt.subplots(nrows=1, ncols=1, figsize=(5.6, 5.1))
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
"""
dataMatrix: matrix for the heatmap
annotation: annotation matrix for the heatmap
"""
newMatrix = np.array(dataMatrix)
annotation = np.array(annotation)
sns.heatmap(
newMatrix, # data matrix
annot=annotation, # annotation matrix
fmt="s",
annot_kws={'fontsize':'11'}, # annotation attributes
linewidth=0.5,
ax=axes,
cbar=False, # color bar
cmap=plt.cm.Blues # color palette
)
axes.set_xticklabels(xlabels, rotation=0)
axes.set_yticklabels(ylabels, rotation=0)
# remove ticks
axes.tick_params(axis='both', which='both', length=0, labelsize='11')
plt.tight_layout()
#fig.savefig('graph.pdf')