Convert colors to grey/grayscale so that you can see how your plot
will look after photocopying or printing to a non-color printer.
Usage
ColToGrey(col)
ColToGray(col)
Arguments
col
vector of any of the three kind of R colors, i.e., either a color name (an element of colors()),
a hexadecimal string of the form "#rrggbb" or "#rrggbbaa" (see rgb), or an integer i meaning palette()[i].
Non-string values are coerced to integer.
Details
Converts colors to greyscale using the formula grey = 0.3*red +
0.59*green + 0.11*blue. This allows you to see how your color plot
will approximately look when printed on a non-color printer or photocopied.
Value
A vector of colors (greys) corresponding to the input colors.
Note
These function was previously published as Col2Grey() in the TeachingDemos package and has been integrated here without logical changes.
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(DescTools)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DescTools/ColToGrey.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ColToGrey
> ### Title: Convert Colors to Grey/Grayscale
> ### Aliases: ColToGrey ColToGray
> ### Keywords: color
>
> ### ** Examples
>
> par(mfcol=c(2,2))
> tmp <- 1:3
> names(tmp) <- c('red','green','blue')
>
> barplot(tmp, col=c('red','green','blue'))
> barplot(tmp, col=ColToGrey(c('red','green','blue')))
>
> barplot(tmp, col=c('red','#008100','#3636ff'))
> barplot(tmp, col=ColToGrey(c('red','#008100','#3636ff')))
>
>
>
>
>
> dev.off()
null device
1
>