[R] adding value labels on Interaction Plot
David Winsemius
dwinsemius at comcast.net
Wed Mar 4 20:06:11 CET 2009
See if this helps. After your code, submit this to R:
with(d, text(xx[xx==3],zz[xx==3],paste("3, ",zz[xx==3])))
After that has convinced you that xx and zz are being used properly,
you can try the more general approach:
with(d, text(xx,zz,paste(xx, " , ", zz)))
I would have used ZZ rather than "Y Label" on the y axis, because yy
is being used as a grouping parameter and the plotted value is really zz
--
David Winsemius
On Mar 4, 2009, at 11:52 AM, Dimitri Liakhovitski wrote:
> Hello - and sorry for what might look like a simple graphics question.
>
> I am building an interaction plot for d:
>
> d
> =
> data
> .frame
> (xx=c(3,3,2,2,1,1),yy=c(4,3,4,3,4,3),zz=c(5.1,4.4,3.5,3.3,-1.1,-1.3))
> d[[1]]<-as.factor(d[[1]])
> d[[2]]<-as.factor(d[[2]])
> print(d)
>
> interaction.plot(d$xx, d$yy, d$zz,
> type="b", col=c("red","blue"), legend=F,
> lty=c(1,2), lwd=2, pch=c(18,24),
> xlab="X Label",
> ylab="Y Label",
> main="Chart Label")
>
> I am trying and not succeeding in adding Y values (value labels in
> Excel speak) near the data points on 3 lines of the graph.
> I understand that I might have to use "text". But how do I tell text
> to use the actual coordinates of the dots on the lines?
>
>
> Thank you very much!
>
> --
> Dimitri Liakhovitski
> MarketTools, Inc.
> Dimitri.Liakhovitski at markettools.com
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list