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
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