[R] Legend symbols (line, points) in one column.
Kenneth Roy Cabrera Torres
krcabrer at une.net.co
Fri Oct 14 12:37:52 CEST 2011
Hi David:
Thank you for your answer.
El vie, 14-10-2011 a las 00:32 -0400, David Winsemius escribió:
> 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.
No, because I want a continous line for the model.
But the data as points, and in the legend to identify each one
as the example shows but in only in one column in the legend!.
>
> This is what I came up with using the panel.lmline rather than
> building it outside the plotting function:
If the model is a linear one, it is fine, but the model could
be a complex one that it is not programmed as "panel.xxmodel", or else.
Thank you very much for your interest in finding the solution.
> 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)
>
More information about the R-help
mailing list