-
Notifications
You must be signed in to change notification settings - Fork 0
/
Correlation_Heatmap.R
44 lines (35 loc) · 1.84 KB
/
Correlation_Heatmap.R
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
# set your working director using setwd()
setwd("C:\\Users\\Daniel Atzberger\\Documents\\SNCS")
# Important note: In the file Results_Correlation_Final.csv we replaced
# the entries 'Silhouette coefficient' by 'Silhouette Coefficient'
# and the entries 'Distance consistency' by 'Distance Consistency'
# using an usual Text Editor
library(reshape)
library(ggplot2)
library(gridExtra)
library(patchwork)
library(RColorBrewer)
df <- read.csv('Results_Correlation_Final.csv')
colors <- brewer.pal(9, "BrBG")
ggplot(df, aes(x = Variable.1, y = Variable.2, fill = Correlation)) +
geom_tile(width = 1.0, position = 'identity') +
geom_text(aes(label = sprintf("%.2f", Correlation)), color = "black", size = 4) +
scale_fill_gradient2(low = colors[1], mid = colors[5], high = colors[9],
midpoint = 0.0, na.value = "grey", limits = c(-1,1)) +
guides(fill = guide_colourbar(barwidth = 1,
barheight = 10,
title = '',
#label = FALSE,
#ticks = FALSE,
reverse = FALSE)) +
theme(axis.ticks.length = unit(5, "pt"),
axis.text.y = element_text(size = 10),
axis.text.x = element_text(size = 10, angle = 330, hjust = 0, colour = "black"),
panel.grid.major = element_blank(), panel.background = element_blank(),
legend.text=element_text(size=8)) +
scale_x_discrete(limits=c('Trustworthiness', 'Continuity', 'Shephard Diagram Correlation',
'7-Neighborhood Hit','Distance Consistency')) +
scale_y_discrete(limits=c('Distance Consistency', '7-Neighborhood Hit',
'Shephard Diagram Correlation','Continuity','Trustworthiness'))+
labs(x = "", y = "") +
coord_equal()