Closed Chandrima-04 closed 2 years ago
I have been trying to color the nodes in my graph:
aro <- read_csv("Aro_Deg.csv") u1 <- unique(unlist(aro[, c("to", "from")])) name <- data.frame(matrix(unlist(u1))) graph <- graph_from_data_frame(aro, name, directed = TRUE) ggraph(graph, layout = 'linear', circular = T) + scale_color_brewer(palette="BuPu") + geom_edge_link(aes(colour = factor(Sub_Type))) + scale_edge_color_brewer(palette = 'Set3') + geom_node_text(aes(label = name), repel = TRUE, size = 1.5) + geom_node_point(aes(color = factor(Sub_Type)))
This is the error I am getting:
Error in factor(Sub_Type) : object 'Sub_Type' not found
The object is certainly loaded as there is no error when I am just using it to color edge links, but when I am adding node colors, I am getting this error.
Is Sub_Type a node attribute? From your code it seems that it is an edge attribute which cannot be used to color nodes.
I have been trying to color the nodes in my graph:
This is the error I am getting:
The object is certainly loaded as there is no error when I am just using it to color edge links, but when I am adding node colors, I am getting this error.