I use graphNEL objects from gRbase and Rgraphviz to plot the graph and would like to color the graph nodes in different (specified) colors when plotting. For example, how could I plot this graph with a and b blue and c and d red?
graphNEL
gRbase
Rgraphviz
a
b
c
d
library(Rgraphviz) library(gRbase) mygraph = dag(~a:c + b:c + b:d) plot(mygraph)
This should work;
nAttrs<-list() nAttrs$color <- c(a = "blue", b = "blue", c = "red", d = "red") plot(g1, nodeAttrs = nAttrs)
see also getDefaultAttrs() to get all graph attributes with default values.
getDefaultAttrs()