Skip to content

Commit fd639b3

Browse files
committed
Update syntax viz
Signed-off-by: Evangelos Lamprou <vagos@lamprou.xyz>
1 parent f16d411 commit fd639b3

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

infrastructure/viz/syntax.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,26 @@ def node_heatmap(df, outdir=None):
122122
# order the y-axis of the heatmap according to the node_order, any nodes not in that list can appear after in any order
123123
heatmap_data = heatmap_data.loc[[x for x in heatmap_data.index if x not in node_order] + list(reversed(node_order))]
124124
annot_data = annot_data.loc[[x for x in annot_data.index if x not in node_order] + list(reversed(node_order))]
125+
126+
# Sort the columns by the sum of the values in each column
127+
heatmap_data = heatmap_data[heatmap_data.sum().sort_values(ascending=False).index]
128+
annot_data = annot_data[heatmap_data.columns]
129+
130+
# Add an overall total column, this should be outside the normalizations
131+
heatmap_data['total'] = heatmap_data.sum(axis=1)
132+
annot_data['total'] = annot_data.sum(axis=1)
133+
134+
heatmap_data = heatmap_data.applymap(lambda x: min(x, limit))
135+
annot_data = heatmap_data.applymap(lambda x: \
136+
#'>{}'.format(limit) \
137+
'*' \
138+
if x == limit else '')
139+
140+
# Set the color limit to be 5
125141

126142
plt.figure(figsize=(5.5, 6))
127143
sns.heatmap(heatmap_data,
128-
cmap='Reds',
144+
cmap='Greys',
129145
annot=annot_data,
130146
fmt='',
131147
cbar_kws={'label': 'Occurrences (* denotes more than 5)',

0 commit comments

Comments
 (0)