getColors: Get colors associated to edges of a gGraph object

getColorsR Documentation

Get colors associated to edges of a gGraph object

Description

The function getColors returns the colors associated to the nodes of a gGraph object, based on a specified node attribute.

Usage

getColors(x, ...)

## S4 method for signature 'gGraph'
getColors(x, nodes = "all", attr.name, col.rules = NULL, ...)

Arguments

x

a valid gGraph.

...

other arguments passed to other methods.

nodes

a vector of character strings or of integers identifying nodes by their name or their index. Can be "all", in which case all nodes are considered.

attr.name

a character string indicating the name of node attribute to be used to define colors.

col.rules

a matrix giving the rules for plotting attribute values with different colors. See details.

Details

Colors are based on a node attribute, that is, on a column of the nodes.attr data.frame. This attribute should have a finite number of values, and would most likely be a factor. Correspondence between values of this variable and colors must be provided in the @meta\$color slot, or as col.rules argument. Color rules mus be provided as a two-column matrix; the first column contains values of a node attribute, and is named after this attribute; the second must be named "color", and contain valid colors.

See example section to know how this slot should be designed.

Value

A vector of characters being valid colors.

Functions

  • getColors(gGraph): Method for gGraph objects

Examples


worldgraph.10k # there is a node attribute 'habitat'
worldgraph.10k@meta$color

head(getNodes(worldgraph.10k))
head(getColors(worldgraph.10k, res.type = "vector", attr.name = "habitat"))


thibautjombart/geograph documentation built on Jan. 27, 2024, 10 p.m.