ck_coherence_matrix <- function(coherence_data) { colnames(coherence_data) <- coherence_columns rownames(coherence_data) <- coherence_columns melt_coherence_data = melt(as.matrix(coherence_data)) coherence_data_plot <- ggplot(data = melt_coherence_data, aes(x=Var1, y=Var2, fill=value) ) + geom_tile(color = "white") coherence_data_plot <- coherence_data_plot + theme_minimal() coherence_data_plot <- coherence_data_plot + scale_fill_gradient2(low="white", high="red", midpoint=0.5, limit=c(0.0,1.0), space = "Lab", name = "Coherence", guide = "colorbar", breaks = c(0.2, 0.4, 0.6) ) coherence_data_plot <- coherence_data_plot + scale_x_discrete(name="", position = "top") + scale_y_discrete(name="", limits = rev(levels(melt_coherence_data$Var2)) ) coherence_data_plot <- coherence_data_plot + theme(legend.title = element_text(size = 10, face = "bold"), legend.text = element_text(size=8, face = "bold"), legend.background=element_rect(fill = "gray90", size = 0.5)) coherence_data_plot <- coherence_data_plot + theme(axis.text.x = element_text(angle=45, vjust=0, size=12, hjust=0, face="bold"), axis.title.x = element_text(size = 16, face="bold"), axis.title.y = element_text(size = 16, face="bold"), axis.text.y = element_text(size = 12, face = "bold") ) coherence_data_plot <- coherence_data_plot + theme(panel.border = element_rect(fill=NA, size=1)) coherence_data_plot <- coherence_data_plot + coord_fixed() return(coherence_data_plot) }