addGGArrows: Add Gradient Vector Arrows to Gradient Field Heatmap.

Description Usage Arguments Value Examples

View source: R/addGGArrows.R

Description

Add vectors indicating the gradient field to the heatmap of the cumulated path lengths.

Usage

1
2
3
addGGArrows(g, centers, gradients, fac = 0.025,
  arrow_len = unit(0.075/2, "inches"), nColumns = 10L, nRows = 10L,
  ...)

Arguments

g

[ggplot]
ggplot-object as created by ggplotHeatmap.

centers

[matrix]
Matrix containing the points of a grid of cells, for which the lengths of cumulated gradient paths should be computed. Each row corresponds to a single point.

gradients

[matrix]
Matrix containing the multi-objective gradients for each point of centers.

fac

[numeric(1L)]
Factor used for scaling the lengths of the gradient vectors. The default is 0.025.

arrow_len

[unit(1L)]
Length of the arrow tips (default: unit(0.075 / 2, "inches")).

nColumns

[integer(1L)]
How many columns of arrows should be drawn? The default is 10.

nRows

[integer(1L)]
How many rows of arrows should be drawn? The default is 10.

...

[any]
Further arguments to be passed to the geom_tile function of ggplot.

Value

[ggplot]
A ggplot object displaying the multi-objective gradient landscape.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Define two single-objective test problems and a grid of points:
fn1 = function(x) sum((x - c(0.2, 1))^2)
fn2 = function(x) sum((x - c(0.5, 0.5))^2)
points = as.matrix(expand.grid(x1 = seq(0, 0.7, 0.005), x2 = seq(0, 1.25, 0.005)))

# Compute the corresponding gradients and the cumulated path lengths:
gradients = computeGradientField(points, fn1, fn2)
x = computeCumulatedPathLengths(points, gradients)

# Visualize the resulting multi-objective "landscape":
g = ggplotHeatmap(x)
g

# Add white arrows of the gradient field to the plot:
addGGArrows(g, points, gradients, color = "white")

kerschke/mogsa documentation built on Oct. 27, 2018, 12:13 a.m.