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

netplot-formulae

Formulas in netplot


Description

Edge colors in both nplot() and set_edge_gpar() can be specified using a formula based on ego() and alter() (source and target). This way the user can set various types of combination varying the mixing of the colors, the alpha levels, and the actual mixing colors to create edge colors.

Usage

color_formula(x, col, alpha, env, type, mix = 1, postfix = NULL)

ego(...)

alter(...)

Arguments

x

An object of class netplot.

col

Any valid color. Can be a single color or a vector.

alpha

Number. Alpha levels

env, type, postfix

For internal use only.

mix

Number. For mixing colors between ego and alter

...

Passed to color_formula.

Value

Nothing. These functions are called internally when using formulas. color_formula modifies the environment env.

Examples

if (require(gridExtra) & require(magrittr)) {
  library(igraph)
  net <- make_ring(4)

  set.seed(1)
  np <- nplot(net, vertex.color = grDevices::hcl.colors(4), vertex.size.range=c(.1, .1))
  np %<>% set_edge_gpar(lwd = 4)

  grid.arrange(
    np,
    np %>% set_edge_gpar(col =~ego + alter),
    np %>% set_edge_gpar(col =~ego(alpha=0) + alter),
    np %>% set_edge_gpar(col =~ego + alter(alpha=0)),
    np %>% set_edge_gpar(col =~ego(mix=0) + alter(mix=1)),
    np %>% set_edge_gpar(col =~ego(mix=1) + alter(mix=0))
  )
}

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.