I draw a graph with a graph, and I would like the edges to have different colors depending on the strength of the joints that they represent. I could set the colors, but I cannot associate them with the strength values ββof the compounds. My current code is as follows:
library(igraph)
library(raster)
library(ggplot2)
library(statnet)
library(qgraph)
connectivityMatrix <- as.matrix(read.table(file=myFile,sep='')))
coordinates <- as.matrix(read.table(file=coordinatesFile))
connectivityMatrix<-connectivityMatrix[1:833,1:833]
CM<-connectivityMatrix[subsetX,subsetY]
COORD<-coordinates[subset,]
net <- as.network(CM, matrix.type = "adjacency", directed = TRUE)
minX<-min(coordinates[,1])
maxX<-max(coordinates[,1])
minY<-min(coordinates[,2])
maxY<-max(coordinates[,2])
p<-plot(net, coord=COORD,xlim=c(minX,maxX),ylim=c(minY,maxY),edge.col=c('red','yellow','cyan','blue'),object.scale=0.005, vertex.col='dimgrey',edge.lwd=1)
Is there a way in the above code to associate the colors specified using edge.col with the range of values ββthat they represent in CM? Thus, the edges corresponding to the value 0-x1 in the connectivity matrix will be displayed in red, x1-x2 in yellow, .... and x3-x4 in blue. x1, x2, x3 are the limits of the range, and x4 is the maximum of CM. Does anyone have an idea on how to do this? Can I add a legend, including the color of the edges and the ranges of values ββthat they represent?
Thank you in advance