Learn R Programming

barsurf (version 0.5.0)

15_fitting_litmus_objects_to_data: Fit Litmus Objects to Data

Description

Functions to fit litmus objects to vectors of data.

Usage

########################################
#general cases
########################################
litmus.fit (x, colvs, …,
    color.space="sRGB", reverse=FALSE, equalize=0.85, na.color="#FFFFFF")

######################################## #wrappers, with predefined colors ######################################## #opaque #high impact heat.litmus.fit (x, …, reverse=FALSE, equalize=0.85) hot.and.cold.fit (x, xb=0)

#opaque #interpolate over hue blue.litmus.fit (x, …, reverse=FALSE, equalize=0.85) green.litmus.fit (x, …, reverse=FALSE, equalize=0.85)

#opaque #dark-color -> light-color -> white blue.litmus.fit.hcv (x, …, reverse=FALSE, equalize=0.85) green.litmus.fit.hcv (x, …, reverse=FALSE, equalize=0.85)

#opaque #interpolate over chroma and lum blue.litmus.fit.flow (x, …, reverse=FALSE, equalize=0.85) green.litmus.fit.flow (x, …, reverse=FALSE, equalize=0.85)

#semitransparent #interpolate over chroma and lum heat.litmus.fit.lum (x, …, reverse=FALSE, equalize=0.85) gold.litmus.fit.lum (x, …, reverse=FALSE, equalize=0.85) blue.litmus.fit.lum (x, …, reverse=FALSE, equalize=0.85) green.litmus.fit.lum (x, …, reverse=FALSE, equalize=0.85) purple.litmus.fit.lum (x, …, reverse=FALSE, equalize=0.85)

#opaque #adapted from colorspace::rainbow_hcl rainbow.litmus.fit (x, …, c=42.5, l=75, start=65, end=315, equalize=0.85) rainbow.litmus.fit.2 (x, …, c=50, l=70, start=0, end=360, equalize=0.85)

#semitransparent glass.rainbow.fit (x, alpha=0.3, …, c=42.5, l=62.5, start=42.5, end=260, equalize=0.85)

Arguments

x

A numeric vector.

xb

Numeric, giving the breakpoint between "hot" and cold".

colvs

A 3-column or 4-column numeric matrix, where each row is one color vector, and the optional fourth column is alpha values.

color.space

A string giving the color space, refer to the details section for litmus objects.

reverse

Logical, reverse the order of the colors.

equalize

Numeric, between zero and one, refer to details.

na.color

A single string representing an R color.

c, l, start, end

Same as colorspace::rainbow_hcl.

alpha

A numeric vector giving the alpha component. If it has two or more values, then each alpha value is assigned to each knot.

Ignored.

Value

All functions return litmus objects, except the hot.and.cold function which returns a mlitmus object.

Details

Refer to the litmus function for background information.

The litmus.fit function constructs a litmus object.

Given n colors, it computes a length-n vector of knots computed from a vector of data.

If equalize is zero, the knots are equally spaced from the lowest x value to the highest. If equalize is one, then knots are selected, such that there's an approximately equal number of points between each pair of knots. And equalization values between zero and one result in an intermediate effect.

Note that high equalize values (higher than the default) may cause color interpolation to appear less smooth.

In general, it's easiest to wrap the litmus.fit function inside another function, which defines the color space and the colors.

This package defines a range of wrapper functions, for the heat, blue, green and purple color themes.

References

Refer to the vignette for an overview, references and better examples.

See Also

litmus

Examples

Run this code
# NOT RUN {
rainbow.litmus.fit.3 <- function (x)
{   colvs <- cbind (c (110, 170, 230, 290), 42.5, 75)
    litmus.fit (x, colvs, color.space="HCL")
}

x <- rnorm (200)
colf <- rainbow.litmus.fit.3 (x)

#evaluate
colf (min (x) )
colf (mean (x) )
colf (max (x) )
# }

Run the code above in your browser using DataLab