[R] Different number of labels in different panels
Hofert Marius
m_hofert at web.de
Mon Dec 31 16:41:08 CET 2007
Hi,
I would like to put a number to each of the plotted curves in each
panel. The problem is that there are different numbers of curves in
different panels, so as you can see from the code below, I could put
the correct numbers to the curves in the first panel, but for the
second panel, both location and number of labels are incorrect (I
would like to have "(1)" at location x=3.5, y=211 and of course no
label "(2)" in the second panel). What is the correct way to solve
this? I have a vector where the i-th entry specifies the number of
curves in panel i, so I somehow have to bring this vector into play...
Thanks very much in advance.
Marius
library(lattice)
column1=c(1,1,1,1,1,1,2,2)
column2=c(1,1,1,2,2,2,1,1)
column3=c(1,2,3,1,2,3,4,5)
column4=c(111,112,113,121,122,123,211,212)
dataframe=data.frame
(panelnumber=column1,curvenumber=column2,x=column3,y=column4)
xyplot(dataframe[,4]~dataframe[,3]|dataframe[,
1],type="l",lty=1,groups=dataframe[,2],layout=c(2,1),aspect=1,
panel=function(...){
panel.xyplot(...)
panel.text(3.4,113,label="(1)")
panel.text(3.4,123,label="(2)")
}
)
More information about the R-help
mailing list