| fcbrewer | R Documentation |
The function generates a vector of color names for a factor(-like) object.
fcbrewer(factor, panel = "Set1")
factor |
A vector of factors. Non-factors will be cast to factors by
calling the |
panel |
This parameter can take three types of values: (1) a color set
name defined in |
When using brewer.pal to generate palettes, the panel is
automatically expanded using colorRampPalette when
the number of levels of the input factor exceeds the limit of respective
panel. This is done automatically.
An fcol object encoding colors matching the factors as well
as the base colors. The latter is often needed in figure legends.
Jitao David Zhang <jitao_david.zhang@roche.com>
brewer.pal.info for color panels.
testFactor <- gl(4,25)
testCol1 <- fcbrewer(testFactor, panel="Set2")
testCol2 <- fcbrewer(testFactor, panel=heat.colors)
testCol3 <- fcbrewer(testFactor, panel="heat.colors")
testCol4 <- fcbrewer(testFactor, panel=c("black", "green", "orange", "lightblue"))
testRan <- runif(100)
## use colors of each item and colors of each level
plot(testRan, pch=21, bg=testCol1)
legend("topright", legend=paste("Class", 1:4),
pch=21, pt.bg=fcbase(testCol1))
## boxplot uses colors matching to each level only
boxplot(testRan ~ testFactor, col=fcbase(testCol1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.