[R] Adding points on top of lines in xyplot
Dylan Beaudette
debeaudette at ucdavis.edu
Tue Nov 20 20:34:35 CET 2007
On Tuesday 20 November 2007, Deepayan Sarkar wrote:
> 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
>
Deepayan,
is there any way to do something similar, but when the data used to plot the
lines and the points come from different dataframes and a grouping variable
is used?
thanks,
Dylan
> > 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.
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the R-help
mailing list