cranvas (version 0.8.5)

extend_ranges: Extend the range of data by an amount

Description

This is useful for setting a margin in the plot region.

Usage

extend_ranges(x, f = qpar("mar"))

Arguments

x
the data vector (either the orginal vector or its range) or an n by 2 matrix which is used to define the ranges of two axes in two columns
f
the amount to extend the range (usually a scalar; when it is a vector, its length must be 2 (giving the amount to extend to the left and right respectively) or 4 (extending x-axis and y-axis respectively)

Value

a vector or a matrix of ranges corresponding to the input x

Examples

Run this code
extend_ranges(c(0, 1))
extend_ranges(1:10)

m <- matrix(c(c(1, 5, 10), c(5, 7, 8)), ncol = 2)
extend_ranges(m)
# larger top and right margins
extend_ranges(m, f = c(0.1, 0.2))
# larger horiz margins, small vertical margins
extend_ranges(m, f = c(0.2, 0.2, 0.1, 0.1))

Run the code above in your browser using DataLab