[R] lattice chart: different definitions for series

ManuelPerera-Chang@fmc-ag.com ManuelPerera-Chang at fmc-ag.com
Mon Nov 7 18:36:39 CET 2005





Hi enthusiasts,

Trying to create a single chart in  lattice with different plotting
definitions for the different series (two series should be drawn with lines
and the other without them)

I am using a dataset, which includes a grouping variable e.g. clinic with
three levels, the variable "year" and a continous variable: "mct".

In the graph the variable "year" is in the x axis, with "mct" represented
in the y axis.

The diagram should include two line diagrams(representing two of the
groups) , with the third group represented only with symbols(no lines).

Until now I was using white lines to eliminate the lines drawn in the third
group, but this solution is not optimal, as the grids are sometimes not
visible

sp<-list(superpose.symbol=list(pch=c(1,2,1),col=c("blue","red","green")),
       superpose.line=list(col=c("blue","red","white"),lty=c(1,2,)))

... and then including

print(xyplot(mct~trend.data$year,groups=clinic,
  scales=list(x=list(at=c(15:pno),labels=per.labels)),
  main=main.title,
  sub=sub.title,
  xlab=x.label,
  ylab=y.label,
  xlim=c(pno-12,pno+1),
  panel=function(x,y,...){panel.grid(h=-1,v=-1,col="grey",lty=2,cex=0.1);
                  panel.superpose(x,y,type="l",lwd=1.8,...);
                  panel.superpose(x,y,type="p",cex=1.8,...))},
  key=sk,
  par.settings=sp));

... was also experimenting, and searching a lot in the WWW for

panel.superpose.2 and type=c("b","b","p"), but without success.

Many thanks,

Manuel




More information about the R-help mailing list