Hello R friends, Simple question today: I am desiring to do an xyplot with the below code, which graphs time series across different experimental Plots- xyplot(AbvBioAnnProd~Year|Plot) ### Plots each monoculture biomass vs time xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){ panel.xyplot(x,y,type="b",pch=16) panel.abline(lm(y~x)) }) What I want to add are unique labels for each panel, where instead of all labeled "plot" with the "slide-bar visual" (although that is okay) I want the Plot number to appear (i.e. the value of "Plot" for that panel). This should be easy, right? -Al -- View this message in context: http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html Sent from the R help mailing list archive at Nabble.com.
Convert "Plot" to factor: xyplot(AbvBioAnnProd ~ Year | Plot, type = c("b", "r"), pch = 16) Also note that using the "type" argument with multiple values prevents the necessity of a custom panel function. HTH, --sundar On Mon, Mar 16, 2009 at 5:54 AM, AllenL <allen.larocque at gmail.com> wrote:> > Hello R friends, > Simple question today: I am desiring to do an xyplot with the below code, > which graphs time series across different experimental Plots- > > xyplot(AbvBioAnnProd~Year|Plot) ? ? ? ?### Plots each monoculture biomass vs > time > xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){ > panel.xyplot(x,y,type="b",pch=16) > panel.abline(lm(y~x)) > }) > > What I want to add are unique labels for each panel, where instead of all > labeled "plot" with the "slide-bar visual" (although that is okay) I want > the Plot number to appear (i.e. the value of "Plot" for that panel). > > This should be easy, right? > -Al > -- > View this message in context: http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >
You should look again at the first example on the xyplot help page, run it, and pay attention to how the strip function works. All should be revealed. I suspect you want something like:> xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){ > panel.xyplot(x,y,type="b",pch=16,strip = strip.custom(strip.levels=TRUE) )> > panel.abline(lm(y~x)) > })-- David Winsemius On Mar 16, 2009, at 8:54 AM, AllenL wrote:> > Hello R friends, > Simple question today: I am desiring to do an xyplot with the below > code, > which graphs time series across different experimental Plots- > > xyplot(AbvBioAnnProd~Year|Plot) ### Plots each monoculture > biomass vs > time > xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){ > panel.xyplot(x,y,type="b",pch=16) > panel.abline(lm(y~x)) > }) > > What I want to add are unique labels for each panel, where instead > of all > labeled "plot" with the "slide-bar visual" (although that is okay) I > want > the Plot number to appear (i.e. the value of "Plot" for that panel). > > This should be easy, right? > -Al > -- > View this message in context: http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
Sorry, I should have xyplot(AbvBioAnnProd ~ Year | factor(Plot), type = c("b", "r"), pch = 16) On Mon, Mar 16, 2009 at 6:17 AM, Sundar Dorai-Raj <sdorairaj at gmail.com> wrote:> Convert "Plot" to factor: > > xyplot(AbvBioAnnProd ~ Year | Plot, type = c("b", "r"), pch = 16) > > Also note that using the "type" argument with multiple values prevents > the necessity of a custom panel function. > > HTH, > > --sundar > > On Mon, Mar 16, 2009 at 5:54 AM, AllenL <allen.larocque at gmail.com> wrote: >> >> Hello R friends, >> Simple question today: I am desiring to do an xyplot with the below code, >> which graphs time series across different experimental Plots- >> >> xyplot(AbvBioAnnProd~Year|Plot) ? ? ? ?### Plots each monoculture biomass vs >> time >> xyplot(AbvBioAnnProd~Year|Plot,panel=function(x,y){ >> panel.xyplot(x,y,type="b",pch=16) >> panel.abline(lm(y~x)) >> }) >> >> What I want to add are unique labels for each panel, where instead of all >> labeled "plot" with the "slide-bar visual" (although that is okay) I want >> the Plot number to appear (i.e. the value of "Plot" for that panel). >> >> This should be easy, right? >> -Al >> -- >> View this message in context: http://www.nabble.com/XYplot-simple-question-tp22537350p22537350.html >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> >