An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130112/2cc36390/attachment-0001.pl>
add categorical labels in plot
2 messages · Elaine Kuo, Jim Lemon
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