Produces color ramps which change simultanously hues, saturation and
values as defined in the hsv modus. This
allows to produce especially smooth transitions from one color to the
next. The default color ramp starts with light blue, continues with
green, yellow, red and ends with dark violet.
Data.frame or matrix with the columns h,s & v
which defines the Intervals for individual color subramps, with
nrow(colInt) = nsr+1 with nsr>1. See details
fr
Fraction of the colors in each of the first nsr-1 subramps.
Details
The function distributes the number of colors in the subramps, given
the fractions fr, as smoothly as possible. The default arguments are
optimized to most distinct colors possible, also for very small
n. There is at least one color in the first and the last
subramp.
Definition of hsv code:
h
Hue of hsv-Signal: 0=red, 1/3=green, 2/3=blue, 1=red.
s
Saturation of hsv-Signal: 0=white, 1=full color.
v
Value of hsv-Signal: 0=black, 1=full color.
Value
A vector of n colors.
Note
If there are subramps which are not adjacent in the color space
(as is here the case for red and violet), you need a virtual subramp
(here from h=0.00 to h=1.00) with corresponding fraction fr == 0.
Author(s)
Rene Locher
See Also
showColors,
ColorBrewer
Examples
IDPcolorRamp(10)
## Default IDPcolorRamp in 21 colors
n <- 21
showColors(IDPcolorRamp(n),border=FALSE)
## colorRamp optimized to return at equidistant indices the colors
## light blue, light green, yellow, orange, red, dark violet
## works fine with n > 7
cInt <- data.frame(h = c(0.47, 0.28, 0.16, 0, 1, 0.8),
s = c(0.31, 0.55, 0.7, 0.8, 0.8, 1),
v = c(1, 1, 1, 1, 1, 0.5))
fr <- c(0.15, 0.25, 0.45, 0.0)
ii <- seq(1,n,length.out=6)
## colors at equidistant indices
showColors(IDPcolorRamp(n, colInt = cInt, fr =fr)[ii], border=FALSE)
## Alternative ramp in 21 colors
showColors(IDPcolorRamp(n, colInt = cInt, fr =fr), border=FALSE)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(IDPmisc)
Loading required package: grid
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/IDPmisc/IDPcolorRamp.Rd_%03d_medium.png", width=480, height=480)
> ### Name: IDPcolorRamp
> ### Title: Color Ramp for Ordered Values
> ### Aliases: IDPcolorRamp
> ### Keywords: color
>
> ### ** Examples
>
> IDPcolorRamp(10)
[1] "#B0FFF1" "#A0FF73" "#BCFF66" "#DEFF59" "#FFF84D" "#FFBC44" "#FF7A3B"
[8] "#FF3333" "#B31272" "#520066"
>
> ## Default IDPcolorRamp in 21 colors
> n <- 21
> showColors(IDPcolorRamp(n),border=FALSE)
>
> ## colorRamp optimized to return at equidistant indices the colors
> ## light blue, light green, yellow, orange, red, dark violet
> ## works fine with n > 7
> cInt <- data.frame(h = c(0.47, 0.28, 0.16, 0, 1, 0.8),
+ s = c(0.31, 0.55, 0.7, 0.8, 0.8, 1),
+ v = c(1, 1, 1, 1, 1, 0.5))
>
> fr <- c(0.15, 0.25, 0.45, 0.0)
> ii <- seq(1,n,length.out=6)
>
> ## colors at equidistant indices
> showColors(IDPcolorRamp(n, colInt = cInt, fr =fr)[ii], border=FALSE)
>
> ## Alternative ramp in 21 colors
> showColors(IDPcolorRamp(n, colInt = cInt, fr =fr), border=FALSE)
>
>
>
>
>
> dev.off()
null device
1
>