Help page of colors() : add a new example ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Help page of colors() : add a new example ?

Millot Gael
Dear all,

May I suggest to add an example in the help page of the colors() function ?
The following code could be useful to easily choose any color from colors() :

## Millot G. (2011), p.71.
## Figure displaying all the 657 built-in color names of colors().
palette(colors())
tempo<-NULL
for(i in 14:1){tempo<-c(tempo, rep(i,50))}
windows(width=10) # replace by quartz(width=10) for MacOS and by X11(width=10) for Linux
par(ann=FALSE, xaxt="n", yaxt="n", bty="n")
plot(rep(1:50,14)[1:657], tempo[1:657], pch=22, bg=1:657, cex=1.5, bty="n")
par(xpd=TRUE)
axis(side=2, at=14:1, labels=, cex.axis=1.5, srt=90)
text(rep(-2, 14), 14:1, as.character((0:13)*50+1), srt=0, cex=1)
text(c(10,20,30,40,50), rep(-0.5,5), c(10,20,30,40,50), srt=0, cex=1)

## palette(colors()) allow to replace the color names by the numbers indicated
## in the figure.
palette(colors())
plot(1, col=630, pch=16, cex=10) # 630 is "tomato"

This code comes from the page 71 of the book I published in french:
Millot G. Comprendre et réaliser les tests statistiques à l'aide de R, 2nd edition. De Boeck editions, Bruxelles . 2011, 767 pages.

I wrote it since my students usually complain about the difficulty to select a color
from colors() when the names are displayed.

Kind regards,

Gael Millot.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Help page of colors() : add a new example ?

Kevin Wright-5
Gael,

Your graph has a lot of white space.  Is that intentional?  I've seen
similar code in other places that uses less white space.

Here's another option for choosing ANY color, not just pre-defined colors.

require(tcltk)
tclvalue(tcl("tk_chooseColor"))


Kevin

On Mon, Jan 30, 2012 at 8:46 AM, Millot Gael <[hidden email]> wrote:

> Dear all,
>
> May I suggest to add an example in the help page of the colors() function ?
> The following code could be useful to easily choose any color from
> colors() :
>
> ## Millot G. (2011), p.71.
> ## Figure displaying all the 657 built-in color names of colors().
> palette(colors())
> tempo<-NULL
> for(i in 14:1){tempo<-c(tempo, rep(i,50))}
> windows(width=10) # replace by quartz(width=10) for MacOS and by
> X11(width=10) for Linux
> par(ann=FALSE, xaxt="n", yaxt="n", bty="n")
> plot(rep(1:50,14)[1:657], tempo[1:657], pch=22, bg=1:657, cex=1.5, bty="n")
> par(xpd=TRUE)
> axis(side=2, at=14:1, labels=, cex.axis=1.5, srt=90)
> text(rep(-2, 14), 14:1, as.character((0:13)*50+1), srt=0, cex=1)
> text(c(10,20,30,40,50), rep(-0.5,5), c(10,20,30,40,50), srt=0, cex=1)
>
> ## palette(colors()) allow to replace the color names by the numbers
> indicated
> ## in the figure.
> palette(colors())
> plot(1, col=630, pch=16, cex=10) # 630 is "tomato"
>
> This code comes from the page 71 of the book I published in french:
> Millot G. Comprendre et réaliser les tests statistiques à l'aide de R, 2nd
> edition. De Boeck editions, Bruxelles . 2011, 767 pages.
>
> I wrote it since my students usually complain about the difficulty to
> select a color
> from colors() when the names are displayed.
>
> Kind regards,
>
> Gael Millot.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


--
Kevin Wright

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Help page of colors() : add a new example ?

djmuseR
In reply to this post by Millot Gael
Here's another graphic that shows R colors in a table, from Earl Glynn
of the Stowers Institute of Medicine:

http://research.stowers-institute.org/efg/R/Color/Chart/

If the link doesn't bring up the page (my didn't initially), Google on
'Earl Glynn Stowers' and look for the link 'Chart of R Colors'.

Dennis


On Mon, Jan 30, 2012 at 6:46 AM, Millot Gael <[hidden email]> wrote:

> Dear all,
>
> May I suggest to add an example in the help page of the colors() function ?
> The following code could be useful to easily choose any color from colors() :
>
> ## Millot G. (2011), p.71.
> ## Figure displaying all the 657 built-in color names of colors().
> palette(colors())
> tempo<-NULL
> for(i in 14:1){tempo<-c(tempo, rep(i,50))}
> windows(width=10) # replace by quartz(width=10) for MacOS and by X11(width=10) for Linux
> par(ann=FALSE, xaxt="n", yaxt="n", bty="n")
> plot(rep(1:50,14)[1:657], tempo[1:657], pch=22, bg=1:657, cex=1.5, bty="n")
> par(xpd=TRUE)
> axis(side=2, at=14:1, labels=, cex.axis=1.5, srt=90)
> text(rep(-2, 14), 14:1, as.character((0:13)*50+1), srt=0, cex=1)
> text(c(10,20,30,40,50), rep(-0.5,5), c(10,20,30,40,50), srt=0, cex=1)
>
> ## palette(colors()) allow to replace the color names by the numbers indicated
> ## in the figure.
> palette(colors())
> plot(1, col=630, pch=16, cex=10) # 630 is "tomato"
>
> This code comes from the page 71 of the book I published in french:
> Millot G. Comprendre et réaliser les tests statistiques à l'aide de R, 2nd edition. De Boeck editions, Bruxelles . 2011, 767 pages.
>
> I wrote it since my students usually complain about the difficulty to select a color
> from colors() when the names are displayed.
>
> Kind regards,
>
> Gael Millot.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Help page of colors() : add a new example ?

Millot Gael
Very nice graphic indeed !
One way or another, it would be useful to have such examples
in the help page of colors().

Thanks for your time !!

Best,

Gael.


> -----Message d'origine-----
> De : Dennis Murphy [mailto:[hidden email]]
> Envoyé : lundi 30 janvier 2012 19:51
> À : Millot Gael
> Cc : [hidden email]
> Objet : Re: [Rd] Help page of colors() : add a new example ?
>
> Here's another graphic that shows R colors in a table, from Earl Glynn
> of the Stowers Institute of Medicine:
>
> http://research.stowers-institute.org/efg/R/Color/Chart/
>
> If the link doesn't bring up the page (my didn't initially), Google on
> 'Earl Glynn Stowers' and look for the link 'Chart of R Colors'.
>
> Dennis
>
>
> On Mon, Jan 30, 2012 at 6:46 AM, Millot Gael <[hidden email]> wrote:
> > Dear all,
> >
> > May I suggest to add an example in the help page of the colors() function ?
> > The following code could be useful to easily choose any color from colors() :
> >
> > ## Millot G. (2011), p.71.
> > ## Figure displaying all the 657 built-in color names of colors().
> > palette(colors())
> > tempo<-NULL
> > for(i in 14:1){tempo<-c(tempo, rep(i,50))}
> > windows(width=10) # replace by quartz(width=10) for MacOS and by
> X11(width=10) for Linux
> > par(ann=FALSE, xaxt="n", yaxt="n", bty="n")
> > plot(rep(1:50,14)[1:657], tempo[1:657], pch=22, bg=1:657, cex=1.5, bty="n")
> > par(xpd=TRUE)
> > axis(side=2, at=14:1, labels=, cex.axis=1.5, srt=90)
> > text(rep(-2, 14), 14:1, as.character((0:13)*50+1), srt=0, cex=1)
> > text(c(10,20,30,40,50), rep(-0.5,5), c(10,20,30,40,50), srt=0, cex=1)
> >
> > ## palette(colors()) allow to replace the color names by the numbers indicated
> > ## in the figure.
> > palette(colors())
> > plot(1, col=630, pch=16, cex=10) # 630 is "tomato"
> >
> > This code comes from the page 71 of the book I published in french:
> > Millot G. Comprendre et réaliser les tests statistiques à l'aide de R, 2nd edition.
> De Boeck editions, Bruxelles . 2011, 767 pages.
> >
> > I wrote it since my students usually complain about the difficulty to select a color
> > from colors() when the names are displayed.
> >
> > Kind regards,
> >
> > Gael Millot.
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel