I'm confused as how to add text in xyplot
. Given the toy example below, I'd like to add the text "A"
, "B"
, "C"
at the far right of the tips of YA
, YB
, and YC
, respectively. I reformatted my data into a data.frame so it mimics my actual dataset. Any tips are greatly welcome
X = seq(1,100,length.out=5)
YA = 4*X + 10
YB = 2*X-5
YC = 0.5*X + 100
Xs = rep(X,3)
Y = c(YA,YB,YC)
index = as.factor(c(rep(1,5),rep(2,5),rep(3,5)))
Mat = data.frame(index,Xs,Y)
levels(Mat$index)=c("A","B","C")
xyplot(Y~Xs,data=Mat,group=index,col=c("blue","red","black"),type="l")