[R] 2d plotting and colours

Mulholland, Tom Tom.Mulholland at dpi.wa.gov.au
Wed Mar 30 09:59:46 CEST 2005


And getting back to your question about the palette

there are a lot of ways to do this

assuming you have just started a session 

palette() 
# will give 
#[1] "black"   "red"     "green3"  "blue"    "cyan"   
#[6] "magenta" "yellow"  "gray"  

palette(rainbow(24))  # There's also 'heat.colors' & 'topo.colors'
palette()

# [1] "red"         "#FF4000"     "#FF8000"    
# [4] "#FFBF00"     "yellow"      "#BFFF00"    
# [7] "#80FF00"     "#40FF00"     "green"      
#[10] "#00FF40"     "#00FF80"     "#00FFBF"    
#[13] "cyan"        "deepskyblue" "#0080FF"    
#[16] "#0040FF"     "blue"        "#4000FF"    
#[19] "#8000FF"     "#BF00FF"     "magenta"    
#[22] "#FF00BF"     "#FF0080"     "#FF0040"   

palette(rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep=".")))
palette()
# [1] "black"   "#110000" "#220000" "#330000" "#440000"
# [6] "#550000" "#660000" "#770000" "#880000" "#990000"
#[11] "#AA0000" "#BB0000" "#CC0000" "#DD0000" "red2"   
#[16] "red" 

If you are looking to use colours that take account of colour blindness
you could try the package dichromat. (I think 2.1 will have some of this inbuilt)

Once you look through the help files associated with some of these options you 
will find the way that best suits your method of working.

Tom






> -----Original Message-----
> From: Uwe Ligges [mailto:ligges at statistik.uni-dortmund.de]
> Sent: Wednesday, 30 March 2005 3:18 PM
> To: TEMPL Matthias
> Cc: r-help at stat.math.ethz.ch; Asha Jayanthi
> Subject: Re: [R] 2d plotting and colours
> 
> 
> TEMPL Matthias wrote:
> 
> > Hi!
> > 
> > There are more than 8 colors.
> 
> Yes, e.g. for rgb space there are 16777216, see ?rgb.
> 
> Uwe Ligges
> 
> 
> 
> > x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
> >                 matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
> >      
> > (cl <- kmeans(x, i, 20))
> >     
> > s <- c("tomato4", "turquoise", "slateblue", "wheat", 
> "snow", "skyblue",
> > "peru", "pink")
> > # see at:    
> > colors()
> >      
> > plot(x, col = s)
> >      
> > points(cl$centers, col = s, pch = 8, cex=2)
> > 
> > 
> > Best,
> > Matthias
> > 
> > 
> > 
> > 
> > 
> >>Hi!
> >>
> >>I am new to R just 3 days in it and i apologize if my 
> >>questions seem very 
> >>trivial and consumed your valuable time.
> >>
> >>I am coding in perl and i stumbled upon R regarding plotting good 
> >>statistical graphs.
> >>
> >>I tried the kmean clustering for a large matrix ,say > 150 * 
> >>150 . I tried 
> >>the example code given in the tutorial to perform 2d plot
> >>
> >># i ranges from 2 to 10
> >>cl <- kmeans(x, i, 20)
> >>plot(x, col = cl$cluster)
> >>points(cl$centers, col = 1:i )
> >>
> >>I see that there are only 8 colours defined , namely 
> >>black,red,green,blue,cyan,magenta,yello,gray.
> >>
> >>How should i set my colour preferences to obtain my palette 
> >>of colours? I  
> >>checked in the totorial which talks about R.colors and 
> >>palatte , but i 
> >>failed to understand how to set it.
> >>
> >>Thank You
> >>
> >>Asha
> >>
> >>
> >>______________________________________________
> >>R-help at stat.math.ethz.ch mailing list 
> >>https://stat.ethz.ch/mailman/listinfo/r-help
> >>PLEASE do read 
> >>the posting guide! http://www.R-project.org/posting-guide.html
> >>
> > 
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list