1

I am plotting a network in R using igraph and want to change the following things:

  • If the weight is 0 there should be no edge.
  • There should be one edge for each of the four attributes parameter (grey edge), feedback (blue edge), design (pink edge) and intent (yellow edge). This means there can be 0-4 edges between two nodes.
  • The node label should always be next to the node in a way that it does not overlap with the edge/arrow.
  • Nodes should have different colors depending on their class (e.g. green for class E and red for class I).

My code so far looks like this:

#install.packages("igraph")
library(igraph)
data <- read.csv(file.choose(), sep=";", header=T)
y <- data.frame(data$From, data$To, data$Weight, data$Class, data$Parameter, data$Feedback, data$Design, data$Intent)
net <- graph.data.frame(y, directed=T)
V(net)
E(net)
V(net)$label <- V(net)$name
V(net)$degree <- degree(net)
hist(V(net)$degree, col="red", main="Histogram of Node Degree", ylab="Frequency", xlab="Degree of Vertices")
set.seed(222)
plot(net, edge.width = y$data.Weight, vertex.color="red", vertex.size=5, edge.arrow.size=1, edge.color="blue", vertex.label.dist=1.5, vertex.label.cex=1, vertex.label.color="black")

And gives me the following plot:

Network plot that wants to be improved according to the bullet points further up:

enter image description here

My dataset looks like this:

enter image description here

I want the code to create this plot instead (example made in PowerPoint):

enter image description here

  • 1
    To make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), please provide your data using `dput()` and avoid posting images of data/code. – jrcalabrese Nov 21 '22 at 01:53

0 Answers0