0

The R Graphics Cookbook shows a "directed graph from a data frame, with the Fruchterman-Reingold algorithm" on p.g 276 (see google books).

Do any opportunities exist to assign different shapes to specific parts of the data.frame and to have the objects filled with text?

Stücke
  • 868
  • 3
  • 14
  • 41
  • This question seems too vague to be answerable. Try including a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data and clearly describe the desired output for that input. Also it's better to include all relevant information from the link in the question itself should that link ever break. – MrFlick Aug 19 '16 at 13:16

1 Answers1

1

The Fruchterman-Reingold algorithm is a layout algorithm. It determines the position of the nodes of the graph. This is independent of the nodes' shape or labelling. In the book's example, remove vertex.label=NA from the plot arguments to display labels. You can change the shape of the nodes with the vertex.shape argument.

library(igraph)
library(gcookbook)

g <- graph.data.frame(madmen2, directed=TRUE)

plot(g, layout=layout.fruchterman.reingold, vertex.size=8, edge.arrow.size=0.5,
 vertex.shape=sample(c("circle", "square", "rectangle"), vcount(g), replace=TRUE))

To fit the label inside the node, see Match vertex size to label size in igraph

Community
  • 1
  • 1