Thanks Duncan! That works! On Sun, May 24, 2015 at 8:09 AM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
> On 24/05/2015 7:47 AM, Brian Smith wrote: > > Hi, > > > > I wanted the rug (in plot) to have different colors. For example: > > > > vals1 <- sample(1:100,5) > > vals2 <- sample(1:100,5) > > > > rugcols <- c("red","blue","brown","red","yellow") > > > > plot(vals1,vals2) > > rug(vals1,col=rugcols,lwd=2) > > > > > > However, with this code I only get 'red' for all the ticks. Is there a > way > > I can get the different colors for rug? > > The rug() function is basically a wrapper for axis(), and it doesn't > support multiple colours of tick marks. So what you could do is call > rug() once for each colour: > > # This line is not needed in your example, but might be in general... > rugcols <- rep(rugcols, length.out=length(vals1)) > > for (col in unique(rugcols)) { > show <- rugcols == col > rug(vals1[show], col=col, lwd=2) > } > > Duncan Murdoch > [[alternative HTML version deleted]] ______________________________________________ R-help@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.