You are here:
Vanderbilt Biostatistics Wiki
>
Main Web
>
Seminars
>
RClinic
>
ColorsFn
(10 Nov 2006,
TheresaScott
)
(raw view)
E
dit
A
ttach
---+ A function that displays the colors you can specify using the =colors()= function R has 657 built-in colors that can be accessed using the =colors()= function. Invoking =colors()= returns a 657 element character vector, where each element of the vector is a specific color name. The =colors()= function can als be used in conjunction with the =[ ]= subsetting operators to extract a specific subset of color names. For example, <highlight> colors()[4:10] </highlight> The following function generates a matrix of rectangles that displays the corresponding color of each of the 657 possible colors you can specify using the =colors()= function. <highlight> show.colors <- function(x=22,y=30){ par(mai=c(.4,.4,.4,.4), oma=c(.2,0,0,.2)) plot(c(-1,x),c(-1,y), xlab='', ylab='', type='n', xaxt='n', yaxt='n', bty='n') for(i in 1:x){for(j in 1:y){ k <- y*(i-1)+j ; co <- colors()[k] rect(i-1, j-1, i, j, col=co, border=1)}} text(rep(-.5,y),(1:y)-.5, 1:y, cex=1.2-.016*y) text((1:x)-.5, rep(-.5,x), y*(0:(x-1)), cex=1.2-.022*x) title('col=colors()[n]') } show.colors() </highlight>
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Edit
w
iki text
|
M
ore topic actions
Topic revision: r2 - 10 Nov 2006,
TheresaScott
Main
Department Home Page
Biostatistics Graduate Program
Vanderbilt University Medical Center
Main Web
Main Web Home
Search
Recent Changes
Changes
Topic list
Biostatistics Webs
Archive
Main
Sandbox
System
Register
|
Log In
Copyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki?
Send feedback