On 01/12/2013 12:01 PM, Elaine Kuo wrote:
Hello
I want to draw a plot using the code below.
Further, I want to add labels (White, Yellow, Red) to x-axis.
Please kindly advise how to add the categorical labels, by modifying the
code.
...
Hi Elaine,
Bit hard to tell exactly what you want, but try this:
ek.data<-data.frame(
skin_color=sample(c("white","yellow","red"),100,TRUE),
body_length=runif(100,80,120))
skin.colors<-c("white","yellow","red")
plot(as.numeric(ek.data$skin_color),ek.data$body_length,
bg=skin.colors[as.numeric(ek.data$skin_color)],pch=21,
xlim=c(0.5,3.5),xaxt="n")
axis(1,at=1:3,labels=skin.colors)
Jim
______________________________________________
R-help@r-project.org mailing list
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.