breakColors: Color palette for (symmetric) breaks

Description Usage Arguments Details Value See Also Examples

View source: R/annHeatmap.R

Description

Given a vector of breaks specifying a set of intervals, this function provides a vector of colors for the indicating the intervals graphically. If the intervals are arranged symmetrically around a specified value, the colors try to reflect this.

Usage

1
breakColors(breaks, colors, center = 0, tol = 0.001)

Arguments

breaks

a vector of breaks

colors

either an explicit vector of colors, or a palette function that takes a number and returns a vector of colors

center

optional center around which to check for symmetry

tol

tolerance (as relative error) for deviation from mathematically exact symmetry

Details

The meaning of symmetrical is rather generous here: it is enough that the intervals specified by breaks are of equal length and that center is one of the breaks. This means we allow for more or less intervals on one side of center.

This really only works well if colors is specified as g2r.colors, which returns a symmetrical color vector (from green to red) if an even number of colors is requested. The whole point is then that if there are more classes to one side of center than to the other, this will be reflected by deeper shades of red or green on the appropriate side.

Value

A vector of colors, of length one less than the number of breaks.

See Also

g2r.colors

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
    ## Fully symmetrical breaks
    br1 = (-3) : 3
    co1 = breakColors(br1, g2r.colors)
    co1
    doLegend(br1, co1, 1)
    
    ## Truncated on one side
    br2 = (-2) : 4
    co2 = breakColors(br2, g2r.colors)
    co2
    doLegend(br2, co2, 1)
    
    ## Does not work with other color schemes
    co3 = breakColors(br2, heat.colors)
    co3
    doLegend(br2, co3, 1)    

alexploner/Heatplus documentation built on May 23, 2021, 2:01 p.m.