Convert pie igraph node shapes to coloredrectangle

rectifyPiegraph(
  g,
  nrow = 2,
  ncol = 5,
  byrow = TRUE,
  whichNodes = seq_len(igraph::vcount(g)),
  ...
)

Arguments

g

igraph object, expected to contain one or more nodes with shape "pie".

nrow, ncol

integer values indicating the default number of rows and columns to use when displaying the colors for each node.

byrow

logical indicating whether each vector of node colors should fill the nrow,ncol matrix by each row, similar to how values are filled in base::matrix() with argument byrow.

whichNodes

integer vector of nodes in g which should be considered. Only nodes with shape "pie" will be converted which are also within the whichNodes vector. By default, all nodes are converted, but whichNodes allows converting only a subset of nodes.

...

additional arguments are ignored.

Value

igraph object where node shapes were changed from "pie" to "coloredrectangle".

Details

This function simply converts an igraph network with "pie" node shapes, to use the "coloredrectangle" node shape provided by the multienrichjam package.

In the process, it transfers related node attributes:

  • "pie.color" are copied to "coloredrect.color"

  • "pie.names" are copied to "coloredrect.names". The "coloredrect.names" can be used to label a color key.

  • "size" is converted to "size2" after applying sqrt(size) * 1.5. The "size2" value is used to define the size of coloredrectangle nodes.