[R] Adding points on top of lines in xyplot

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Nov 20 20:17:23 CET 2007


On Nov 20, 2007 11:14 AM, David Afshartous <dafshartous at med.miami.edu> wrote:
>
> All,
>
> I'm trying to make a basic plot: data points superimposed upon the a line
> connecting the points w/ a different color.  Example below doesn't work as
> the first xyplot call doesn't remain.  Suggestions?

xyplot(y ~ Hour, type = 'b', lwd = 2, pch= 16, col.symbol =  "red", cex=3)

or for finer control

xyplot(y ~ Hour,
       panel = function(x, y, ...) {
           panel.lines(x, y, lwd = 2)
           panel.points(x, y, pch = 16, cex = 3, col = "red")
       })

-Deepayan

>
> David
>
>
> Hour = c(NA,1,2,3,4)
> y = c(2,2,3,2,1.5)
>
> xyplot(y ~ Hour, xlab = list("Hour", font=2, cex=2), ylab= list("U_x * V",
> font=2, cex=2), type = 'l', scales = list( x= list(tick.number=5, cex=2,
> limits=c(0,4.5)), y=list(cex=0)), lines=TRUE, lwd = 2 , add=TRUE    )
>
>
> xyplot(y ~ Hour, xlab= "", ylab="", pch= 16, col=  "red", cex=3 , xlim =
> c(0, 4.5), add=TRUE    )



More information about the R-help mailing list