Re: [R] 2d plotting and colours

From: Gregoire Thomas <gregoire.thomass_at_gmail.com>
Date: Fri 08 Apr 2005 - 02:23:55 EST

And does this work?

n <- 5
par(mfrow = c(2,2))
palette("default")
barplot(1:25,col = 1:25)
pal <- rainbow(n)
barplot(1:25,col = pal[(1:25-1)%%n+1])
pal <- rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep=".")) barplot(1:25,col = pal[(1:25-1)%%n+1])

Earl F. Glynn wrote:

>"Mulholland, Tom" <Tom.Mulholland@dpi.wa.gov.au> wrote in message
>news:33F91FB3FDF42E4180428AC66A5CF30B02D3BAB0@afhex01.dpi.wa.gov.au...
>
>
>>Since I was only concentrating on colour issues and not on your specific
>>
>>
>problem I was just showing the possibilities.
>
>
>>Does this code help
>>
>>n <- 5
>>par(mfrow = c(2,2))
>>palette("default")
>>barplot(1:25,col = 1:25)
>>palette(rainbow(n))
>>barplot(1:25,col = 1:25)
>>palette(rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep=".")))
>>barplot(1:25,col = 1:25)
>>
>>
>>require(cluster)
>>x <- runif(100) * 8 + 2
>>cl <- kmeans(x, n)
>>palette(rainbow(n))
>>plot(x, col = cl$cluster)
>>abline(h = cl$centers, lty = 2,col = "grey" )
>>palette(palette()[order(cl$centers)])
>>points(x,col = cl$cluster,pch = 20,cex = 0.4)
>>
>>
>
>Using Windows with R 2.0.1 this looks fine at first.
>
>But when I resize the graphic, copy the graphic to a metafile and paste it
>into Word, or go to an earlier graphic and come back using "History", the
>colors ae all messed up. It's as if only the last palette is being used for
>all four plots in the figure. Oddly, if I copy the graphic as a bitmap, the
>colors are preseved in the bitmap. Is this a quirk of my machine or does
>this happen for others?
>
>Is it possible that the Windows palette manager is being used (which is such
>about obsolete) and that true color graphics are not being used (which is
>the easist way to avoid headaches from the Windows palette manager)?
>
>efg
>
>______________________________________________
>R-help@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@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 Received on Fri Apr 08 02:30:29 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:03 EST