likertColor

0th

Percentile

Selection of colors for Likert plots.

Selection of colors for Likert plots.

Keywords
hplot
Usage
ColorSet(nc, ReferenceZero=NULL)
likertColor(nc, ReferenceZero=NULL,
                colorFunction=c("diverge_hcl","sequential_hcl"),
                colorFunctionOption=c("lighter","flatter","default"),
                colorFunctionArgs=
                  likertColorFunctionArgs[[colorFunctionOption, colorFunction]],
                ...)
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
colorFunction
Function name from the colorspace package, either "diverge_hcl" or "sequential_hcl".
colorFunctionOption
Name of a list item defined inside the likertColor function. The item contains a list of parameters to the function identified in the colorFunction argument.
colorFunctionArgs
list of arguments to the colorspace function. The default selects the values by indexing into a list defined in the likertColor function using the values of the two arguments colorFunction and colo
...
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.
Details

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

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. likertColor returns a subset of a palette constructed by either diverge_hcl or sequential_hcl in the colorspace package. The subset corresponds to the levels specified by ColorSet. brewer.pal.likert returns a RColorBrewer palette. likertColorBrewer returns a subset of a palette constructed by brewer.pal.likert. The subset corresponds to the levels specified by ColorSet.

See Also

plot.likert

Aliases
  • likertColor
  • likertColorBrewer
  • brewer.pal.likert
  • ColorSet
Examples
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

## Examples illustrating the six predefined likertColor palettes, and how
  ## to define additional hcl color palettes for use with the likert functions.

  data(ProfDiv)
  ProfDiv.df <- data.frame(ProfDiv)

  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE)
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE,
         colorFunctionOption="default")
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE,
         colorFunctionOption="flatter")
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl")
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl", colorFunctionOption="default")
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl", colorFunctionOption="flatter")

  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE)
  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE,
         colorFunctionOption="default")
  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE,
         colorFunctionOption="flatter")
  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl")
  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl", colorFunctionOption="default")
  likert(ProfDiv, horizontal=FALSE, positive.order=FALSE,
         colorFunction="sequential_hcl", colorFunctionOption="flatter")

  likertMosaic(ProfDiv.df)
  likertMosaic(ProfDiv.df, colorFunctionOption="default")
  likertMosaic(ProfDiv.df, colorFunctionOption="flatter")
  likertMosaic(ProfDiv.df, colorFunction="sequential_hcl")
  likertMosaic(ProfDiv.df, colorFunction="sequential_hcl",
               colorFunctionOption="default")
  likertMosaic(ProfDiv.df, colorFunction="sequential_hcl",
               colorFunctionOption="flatter")

  ## specify an hcl palette for use with the likert functions.
  BlueOrange <- likertColor(nc=4, ReferenceZero=NULL,
                            colorFunction="diverge_hcl",
                            colorFunctionArgs=
                              list(h=c(246, 40), c=96, l=c(65,90), power=1.5))
  likert( ~ . , ProfDiv.df, horizontal=FALSE, positive.order=FALSE, col=BlueOrange)
Documentation reproduced from package HH, version 2.3-42, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.