Thanks for the tip -----Original Message----- From: Eric Berger <ericjber...@gmail.com> Sent: Thursday, October 27, 2022 2:49 AM To: reichm...@sbcglobal.net Cc: Rui Barradas <ruipbarra...@sapo.pt>; R-help@r-project.org Subject: Re: [R] Color Nodes
You may want to change the color of the vertex labels. e.g. plot(g, vertex.size = 20, vertex.label.dist = 0.5, vertex.color = V(g)$color, vertex.label.color="cyan") On Thu, Oct 27, 2022 at 1:52 AM Jeff Reichman <reichm...@sbcglobal.net> wrote: > > Yes Rui that will work for my needs thank you > > -----Original Message----- > From: Rui Barradas <ruipbarra...@sapo.pt> > Sent: Wednesday, October 26, 2022 4:40 PM > To: reichm...@sbcglobal.net; R-help@r-project.org > Subject: Re: [R] Color Nodes > > Às 21:37 de 26/10/2022, Jeff Reichman escreveu: > > R-Help > > > > > > > > For those of you who use igraph is there a way to highlight (color) > > particular notes. For example if I want to color the "Peter" node > > red and everything else blue or leave default) how would I do that > > or can I do that. Seems as though I might create an attribute column - > > maybe?? > > > > > > > > Jeff > > > > > > > > library(igraph) > > > > > > > > # define links in data > > > > edges <- rbind(c("Dave", "Jenny"), c("Peter", "Jenny"), c("John", > > "Jenny"), c("Dave", "Peter"), c("Dave", "John"), c("Peter", "Sam"), > > c("Sam", "Albert"), c("Peter", "John")) > > > > > > > > # generate and plot graph > > > > # set argument directed = FALSE in graph.edgelist() to plot an > > undirected graph. > > > > g <- graph.edgelist(edges, directed = FALSE) > > > > plot(g, vertex.size = 1, vertex.label.dist = 0.5) > > > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > Hello, > > After creating the graph, set the vertices colors by subsetting V(g). > Here are two exaples, the first color Peter red and leave the others with > their default color. The second, color the other vertices blue. > > > > V(g)["Peter"]$color <- "red" > > plot(g, vertex.size = 20, vertex.label.dist = 0.5, > vertex.color = V(g)$color) > > V(g)$color <- "blue" > V(g)["Peter"]$color <- "red" > plot(g, vertex.size = 20, vertex.label.dist = 0.5, > vertex.color = V(g)$color) > > > > Hope this helps, > > Rui Barradas > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.