Skip to content

Legend symbols (line, points) in one column.

6 messages · R. Michael Weylandt, David Winsemius, Kenneth Cabrera +1 more

#
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
#
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?:
#
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)
#
Hi David:

Thank you for your answer.

El vie, 14-10-2011 a las 00:32 -0400, David Winsemius escribi?:
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!.
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.
1 day later
#
On Fri, Oct 14, 2011 at 10:02 AM, David Winsemius
<dwinsemius at comcast.net> wrote:
A 'lines' component can actually contain points as well, with type="p", as in

xyplot(y~x,group=type,
       type=c("p","l"),
       key=list(space="right",text=list(c("Data","Model")),
                lines=list(lwd = 2, cex = 1.5, pch = 19,
                           type = c("p", "l"))),
       par.settings=confMisc1,
       distribute.type=TRUE,
       data=dataT)

-Deepayan
1 day later
#
Thank you very much for your answer.

It works just as I want!.

Kenneth

El s?b, 15-10-2011 a las 20:39 +0530, Deepayan Sarkar escribi?: