[R] Opposite color in R

Duncan Mackay dulcalma at bigpond.com
Wed Jul 29 04:48:59 CEST 2015


Hi

I plotted the 'spectrum' and it looked a little small - spectrum colours: red orange yellow green blue indigo violet.
I suppose you could go to infinite lengths to split it up but is this an improvement?

I have not gone into the "depths" of complimentary colours

library(colorspace)

ColorsRYB=rbind(colorRamp(c("purple","violet"))((0:4)/4)[1:4,],
                colorRamp(c("violet","blue"))((0:4)/4)[1:4,],
                colorRamp(c("blue","green"))((0:4)/4)[1:4,],
                colorRamp(c("green","yellow"))((0:4)/4)[1:4,],
                colorRamp(c("yellow","orange"))((0:4)/4)[1:4,],
                colorRamp(c("orange","red"))((0:4)/4)[1:4,],
                colorRamp(c("red","purple"))((0:4)/4)[1:4,])

LenCol=length(ColorsRYB[,1])

ColorsRYBhex=rep(0, LenCol)
for(i in 1: LenCol)
{
ColorsRYBhex[i]=rgb(ColorsRYB[i,1]/255,ColorsRYB[i,2]/255,ColorsRYB[i,3]/255)
}

pie(rep(1, LenCol), col = ColorsRYBhex)

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au




-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Atte Tenkanen
Sent: Tuesday, 28 July 2015 18:22
To: r-help at r-project.org
Subject: [R] Opposite color in R

It seems that there is no implementation for the "traditional artist's 
color circle" in R. However I'm searching for such a wheel, because my 
program needs it.

As said, the description of complementary/opposite-function in package 
"colortools" is misleading since, for example

opposite("green") produces violet, not red, but the description of 
complementary-function says

"Complementary or opposite color scheme is formed by colors that are 
opposite each other on the color wheel (example: red and green)."

So, there must be just a lapse in the text.

I "constrained" such kind of a color wheel, which is enough near of what 
I need:

library(colorspace)

ColorsRYB=rbind(colorRamp(c("red", 
"violet"))((0:4)/4)[1:4,],colorRamp(c("violet", 
"blue"))((0:4)/4)[1:4,],colorRamp(c("blue", 
"green"))((0:4)/4)[1:4,],colorRamp(c("green", 
"yellow"))((0:4)/4)[1:4,],colorRamp(c("yellow", 
"orange"))((0:4)/4)[1:4,],colorRamp(c("orange", "red"))((0:4)/4)[1:4,])

LenCol=length(ColorsRYB[,1])

ColorsRYBhex=rep(0, LenCol)
for(i in 1: LenCol)
{
ColorsRYBhex[i]=rgb(ColorsRYB[i,1]/255,ColorsRYB[i,2]/255,ColorsRYB[i,3]/255)
}

pie(rep(1, 24), col = ColorsRYBhex)

Atte T.


28.7.2015, 2.23, Steve Taylor kirjoitti:
> I wonder if the hcl colour space is useful?  Varying hue while keeping chroma and luminosity constant should give varying colours of perceptually the same "colourness" and brightness.
>
> ?hcl
> pie(rep(1,12),col=hcl((1:12)*30,c=70),border=NA)
>
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Atte Tenkanen
> Sent: Sunday, 26 July 2015 7:50a
> To: r-help at r-project.org
> Subject: [R] Opposite color in R
>
> Hi,
>
> I have tried to find a way to find opposite or complementary colors in R.
>
> I would like to form a color circle with R like this one:
> http://nobetty.net/dandls/colorwheel/complementary_colors.jpg
>
> If you just make a basic color wheel in R, the colors do not form
> complementary color circle:
>
> palette(rainbow(24))
> Colors=palette()
> pie(rep(1, 24), col = Colors)
>
> There is a package ”colortools” where you can find function opposite(),
> but it doesn’t work as is said. I tried
>
> library(colortools)
> opposite("violet") and got green instead of yellow and
>
> opposite("blue") and got yellow instead of orange.
>
> Do you know any solutions?
>
> Atte Tenkanen
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list