HH (version 2.3-37)

likertColor: Selection of colors for Likert plots.

Description

Selection of colors for Likert plots.

Usage

ColorSet(nc, ReferenceZero=NULL)
likertColor(nc, ReferenceZero=NULL, ...)
likertColorBrewer(nc, ReferenceZero=NULL, BrewerPaletteName="RdBu", middle.color="gray90")

brewer.pal.likert(n, name, middle.color)

Arguments

n, nc
Number of colors in the palette. If there are more levels than RColorBrewer normally handles, we automatically interpolate with colorRampPalette.
ReferenceZero
Numeric scalar or NULL. The position in the range seq(0, attr(x, "nlevels")+.5, .5) where the reference line at 0 will be placed. attr(x, "nlevels") is the number of columns of the original argument
...
Other arguments are ignored.
BrewerPaletteName, name
RColorBrewer palette names. We default to the diverging palette RdBu. Diverging palettes are usually appropriate for two-directional scales (Agree--Disagree). S
middle.color
Darker middle color than the default "#F7F7F7" in the RdBu scheme.

Value

  • ColorSet returns a vector of integers, one per each level, corresponding to the strength of the levels from Disagree to Agree. For balanced levels, such as c("Disagree Strongly", "Disagree Weakly", "Agree Weakly", "Agree Strongly"), corresponding to nc=4, ReferenceZero=2.5, it returns -2 -1 1 2. For unbalanced levels, such as c("Disagree", "Neutral", "Agree Weakly", "Agree Strongly"), corresponding to nc=4, ReferenceZero=2, it returns -1 0 1 2. brewer.pal.likert returns a RColorBrewer palette. likertColor returns a subset of a palette constructed by brewer.pal.likert. The subset corresponds to the levels specified by ColorSet.

Details

These are support functions for the plot.likert function. Please see plot.likert for details. likertColor uses the diverge_hcl default diverging palette. likertColorBrewer by default uses the "RdBu" diverging palette from RColorBrewer.

See Also

plot.likert

Examples

Run this code
brewer.pal.likert(4, "RdBu")
brewer.pal.likert(5, "RdBu")
ColorSet(4)
ColorSet(4, 2)
likertColor(4)
likertColor(4, 2.5) ## same as above
likertColor(4, 2)   ## one negative level and two positive levels: default
likertColor(5, 3)[-2] ## one negative level and two positive levels: stronger negative

Run the code above in your browser using DataCamp Workspace