layout_centering: Functions to center and normalize the coordinates of a...

layout.centerR Documentation

Functions to center and normalize the coordinates of a network plot within a window.

Description

The layout.center function takes a matrix of coordinates and an x- and y-coordinate range and centers the input coordinates within the range.

The layout.normalize function takes a matrix of coordinates and rescales them to the range (-1,1). If keep.aspect.ratio=FALSE, x- and y-coords are rescaled independently.

Usage

layout.center(coords, xlim, ylim)
layout.normalize(coords, keep.aspect.ratio = TRUE)

Arguments

coords

two column numeric matrix of coordinates.

xlim

two element numeric vector giving min and max of x axis

ylim

two element numeric vector giving min and max of y axis

keep.aspect.ratio

boolean, if FALSE, x- and y-axis will be rescaled indpendently

Details

These functions are used internally, but can also be called by the user when manipulating coordinates for layouts, especially when the coordinate ranges for a sequence of layouts do not match up well. TODO: add barycenter function, and center on vertex function

Value

The input two column numeric matrix of coordinates with positions transformed.

Author(s)

skyebend

Examples

data(McFarland_cls33_10_16_96)
coords<-plot(cls33_10_16_96)

# center layout coords with 100 unit area
layout.center(coords,xlim=c(0,100),ylim=c(0,100))

# rescale layout coords to unit interval
layout.normalize(coords)

ndtv documentation built on July 4, 2024, 5:08 p.m.