Legends are built in columns. You need to find a graphics symbol to
put in the "points" column or you need to find something that the
lines paramater will turn into a dot (and I'm not sure what that might
be.) My suggestion would be to change the line type to dashed and use
" - - -" for the pch argument.
This is what I came up with using the panel.lmline rather than
building it outside the plotting function:
x<-1:5
y<-1*x+rnorm(10)
data1<-data.frame(x,y,type=rep("data",length(x)))
require(lattice)
xyplot(y~x,group=type,
type=c("p","l"), lty=3, lwd=2, cex=4,
key=list(space="right",text=list(c("Data","Model")),
points=list(pch = c(".", "-"),cex=c(4,1.5)) ),
par.settings=confMisc1,
panel=function(x,y,...){panel.xyplot(x,y,...)
panel.lmline(x,y,...)},
distribute.type=TRUE,
data=data1)
--
David.
On Oct 13, 2011, at 11:29 PM, Kenneth Roy Cabrera Torres wrote:
It is about the legend.
As you see in the example the line is not above the points symbol.
I want the line in the symbol in the same column.
Thank you for you interest in helping me.
Have nice day!
El jue, 13-10-2011 a las 22:40 -0400, R. Michael Weylandt escribió:
Looking at your provided example (thank you!), I'm not entirely sure
what you want to put in the same column. Could you perhaps clarify --
is it something about the plot itself or the legend?
Michael
On Thu, Oct 13, 2011 at 8:00 AM, Kenneth Roy Cabrera Torres
<krcab...@une.net.co> wrote:
Dear R users:
I want to have in the same column both symbols, line and
points, one for a data, and the other for the model.
How can I do that?
Or is there other better form to show both data and model
in the same graphic? I need to make the difference on time
of the same subject (repeated measurements on time)
Problem example:
###########################################################
x<-1:5
y<-1*x+rnorm(10)
data1<-data.frame(x,y,type=rep("data",length(x)))
model1<-lm(y~x,data=data1)
data2<-data.frame(x=seq(0,6,.1))
data2$y<-predict(model1,newdata=data2)
data2$type<-rep("model",nrow(data2))
dataT<-rbind(data1,data2)
dataT
require(lattice)
confMisc1<- simpleTheme(pch = c(19,1),lwd=c(2,1),cex=1.5,
lty=1,col=c("black"))
xyplot(y~x,group=type,
type=c("p","l"),
key=list(space="right",text=list(c("Data","Model")),
points=list(pch=c(as.integer(NA),19)),
lines=list(lty=c(1,0),lwd=c(2,0))),
par.settings=confMisc1,
panel=panel.superpose,
distribute.type=TRUE,
data=dataT)
###########################################################
______________________________________________
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.
______________________________________________
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.
______________________________________________
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.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.