ToBW.likert | R Documentation |
Change colors in a likert plot to shades of Black and White. This
function is tailored for a likert
plot, an example of a
"trellis"
object. likert
is based on
panel.bwplot
. There are other places in the structure of
a more general "trellis"
object where colors are stored.
The specifics for this plot is (1) that the colors for negative values in
the plot are in reverse order and (2) the color for a neutral-position panel appears on
both the positive and negative side. The default values are for
three items on the negative side, two on the positive side, and no
neutral.
See the examples for an example with a neutral.
ToBW.likert(x,
colLegendOrder=c("gray70", "gray20", "gray60", "gray75", "gray45"),
## ^Ask Refu ^Imp | Impt Essn
##
colBarchartOrder=colLegendOrder[c(3,2,1,4,5)],
## ^Imp Refu ^Ask | Impt Essn
columns=5)
## negative colors are in reverse order in the BarchartOrder
x |
|
colLegendOrder |
Revised value of |
colBarchartOrder |
Revised value of both |
columns |
Revised value of |
"trellis"
object, identical to the input object except for the colors.
Richard M. Heiberger <rmh@temple.edu>
likert
tmp <- array(1:20, c(4, 5),
list(letters[1:4],
c("NotAsked","VeryNegative","Negative","Positive","VeryPositive")))
tmp
Ltmp <- likert(tmp, ReferenceZero=3.5, col=c("gray85", likertColor(4)), as.percent=TRUE)
Ltmp
ToBW.likert(Ltmp)
## with neutral
tmp2 <- array(1:20, c(4, 5),
list(letters[1:4],
c("VeryNegative","Negative","Neutral","Positive","VeryPositive")))
tmp2
Ltmp2 <- likert(tmp2, ReferenceZero=3, col=likertColor(5),
as.percent=TRUE, main="Neutral")
Ltmp2
ToBW.likert(Ltmp2,
colLegendOrder=c("gray20", "gray60", "gray85", "gray75", "gray45"),
## Neu|tral
colBarchartOrder=c("gray85", "gray60", "gray20", "gray85", "gray75", "gray45")
## Neutral left Neutral right
)
update(main="Wrong way to handle neutral",
ToBW.likert(Ltmp2,
colLegendOrder=c("gray20", "gray60", "gray85", "gray75", "gray45"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.