Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

make_colors

Create a vector of colors for vertices and edges


Description

Using vertex/edge attributes, these functions return vectors of colors that can be used either during the creation of the nplot object, or afterwards when changing gpar (graphical parameter) values with set_gpar.

Usage

make_colors(dat, categorical = FALSE, color_map = grDevices::hcl.colors)

make_edges_colors(x, eattr, ...)

make_vertex_colors(x, vattr, ...)

Arguments

dat

A vector of data to generate the color from.

categorical

Logical. When TRUE sets the colors as categories.

color_map

A function to generate a palette.

x

A graph of class network or igraph.

...

Further arguments passed to make_colors.

vattr, eattr

Character. Names of either vertex or edge variables to be used for generating the colors.

Details

If no attribute is provided, then by defaul the colors are set according to indegree.

x can be either a graph of class igraph or network.

Value

A vector of colors with the attribute color_map. The color map used to generate the colors.

Examples

data(UKfaculty, package="igraphdata")
col <- make_vertex_colors(UKfaculty, "Group")

if (require(magrittr)) {

  nplot(UKfaculty) %>%
    set_vertex_gpar("core", fill = col, col=col) %>%
    set_vertex_gpar("frame", fill = col, col=col, alpha=.7) %>%
    set_edge_gpar(col="gray50", fill="gray50", alpha=.5)
}

netplot

Beautiful Graph Drawing

v0.1-1
MIT + file LICENSE
Authors
George Vega Yon [aut, cre] (<https://orcid.org/0000-0002-3171-0844>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.