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? 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 )
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 )
Try this: 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) trellis.focus("panel", 1, 1, highlight = FALSE) print(panel.points(Hour, y, pch = 16, cex = 3, col = "red")) trellis.unfocus() On Nov 20, 2007 2:14 PM, 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? > > 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 ) > > ______________________________________________ > R-help at 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. >
Reasonably Related Threads
- Lattice, stripplot (xyplot), plotting data with median line, numeric x-axis
- Replacing plot symbols w/ subject IDs in xyplot()
- "symbol print-name too long"
- Connecting lines across missing data points, xyplot
- Xyplot, multi line title via main, all lines left justified