# NOT RUN {
# HCL color wheels/rectangles
#----------------------------
# set in.order to TRUE for hues ordered by their number
# color spectrum of 12 hcl colors ordered by hue from 0
# by intervals of 360/12 = 30 degrees
getColors(in.order=TRUE)
# pastel hcl colors, set luminance to 85 from default of 55
getColors(in.order=TRUE, l=85)
# color wheel of 36 ordered hues around the wheel
getColors(n=36, shape="wheel", border="off", in.order=TRUE)
# ggplot qualitative colors, here for 3 colors generated
# in order of their hue numbers across the color wheel
# starting at a hue of 15 degrees and luminance of 60
getColors(h=15, n=3, l=60, in.order=TRUE)
# HCL Qualitative Scale
# ---------------------
# default pre-defined 12 hcl colors that were manually reordered
# so that adjacent colors achieve maximum separation
getColors()
# deep rich colors for HCL qualitative scale
getColors(c=90, l=45)
# HCL Sequential Scales
# ---------------------
# generate hcl blue sequence with c=65 and vary l
getColors("blues", labels=FALSE)
# generate yellow hcl sequence with varying chroma
getColors("yellows", c=c(20,90), l=65)
# generate custom hue color sequence close to colorbrewer Blues
# library(RColorBrewer)
# getColors(brewer.pal(6,"Blues"))
# compare, vary both l and c
getColors(h=230, n=6, l=c(96,30), c=c(5,80))
# a standard R color sequence
getColors("heat")
# HCL Divergent Scales
# --------------------
# seven colors from rust to blue
getColors("rusts", "blues", n=7)
# add a custom value of chroma, c, to make less saturated
getColors("rusts", "blues", n=7, c=45)
# Manual Specification of Colors
# ------------------------------
# individually specified colors
getColors(c("black", "blue", "red"))
# custom sequential range of colors
getColors(clr="aliceblue", end.clr="blue")
# Plots
# -----
mydata <- rd("Employee", in.lessR=TRUE)
# default quantitative scale
bc(Dept, fill=getColors())
# or with implicit call to getColors
bc(Dept, fill="colors")
# or an implicit call with the blues
bc(Dept, fill="blues")
# even though we have a bar graph, also want the
# graph of the colors as well as the text listing of the colors
bc(Dept, fill=getColors("blues", output="on"))
# custom hue with different chroma levels (saturations)
BarChart(Dept, fill=getColors(h=230, c=c(20,60), l=65, n=5))
# custom hue with different luminance levels (brightness)
# if explicitly calling getColors need to also specify n
Histogram(Salary, fill=getColors(h=230, c=65, l=c(90,30), n=10))
# use the default qualitative viridis color scale
# library(viridis)
# bc(Dept, fill=getColors(viridis_pal()(5)))
# }
Run the code above in your browser using DataLab