Les
2011-Apr-05 18:37 UTC
[R] Arrangement of Lattice Histograms - Top to bottom and then left to right?
Hi List, Using Lattice, I have created a plot of histograms showing Fork Length by Year. The plot shows the histograms in 3 columns and 5 rows. Using the as.table=T function I can get the years to start on top. However, what I would like to do is have the first year start in the top left (column 1, row 1; as it is now) and add the subsequent histograms to the plot going down the column and then over by row (example and current code is shown below). Is this possible? I have spent a great deal of time searching, and have not found any clues. Any help/ideas would be greatly appreciated. For example, what is being done now: 1974 1975 1976 1977 1978 1979 1980 1981 1982 and what I am hoping for: 1974 1977 1980 1975 1978 1981 1976 1979 1982 Thank you kindly, Les data=read.csv("AllData.csv",sep=",",header=T) data$year=as.factor(data$year) ferg=data[data$wtrbody=="Ferguson",c(1:12)] library(lattice) strip.background=trellis.par.get("strip.background") trellis.par.set(strip.background = list(col = grey(7:1/8))) histogram(~fl|year, data=ferg, as.table=T, type="count", col='dark grey',layout=c(3,5),lwd=2, lty=1, xlab=list("Fork Length (mm)", cex=1.4,font=2), breaks=seq(from=300,to=900,by=25), ylab=list("Frequency",cex=1.4,font=2), scales=list(font=2,cex=1.1, tck=c(1,0), alternating=1, y=list(relation="free",tick.number=3)), par.strip.text=list(cex=1.2),font=2, aspect=0.6) -- View this message in context: http://r.789695.n4.nabble.com/Arrangement-of-Lattice-Histograms-Top-to-bottom-and-then-left-to-right-tp3428825p3428825.html Sent from the R help mailing list archive at Nabble.com.
Bert Gunter
2011-Apr-05 19:04 UTC
[R] Arrangement of Lattice Histograms - Top to bottom and then left to right?
Look for the index.cond argument at the bottom of the Help page for xyplot. -- Bert On Tue, Apr 5, 2011 at 11:37 AM, Les <lnharris at zoology.ubc.ca> wrote:> Hi List, > Using Lattice, I have created a plot of histograms showing Fork Length by > Year. The plot shows the histograms in 3 columns and 5 rows. Using the > as.table=T function I can get the years to start on top. However, what I > would like to do is have the first year start in the top left (column 1, row > 1; as it is now) and add the subsequent histograms to the plot going down > the column and then over by row (example and current code is shown below). > Is this possible? I have spent a great deal of time searching, and have not > found any clues. Any help/ideas would be greatly appreciated. > > For example, what is being done now: > > 1974 1975 1976 > 1977 1978 1979 > 1980 1981 1982 > > and what I am hoping for: > > 1974 1977 1980 > 1975 1978 1981 > 1976 1979 1982 > > Thank you kindly, > Les > > data=read.csv("AllData.csv",sep=",",header=T) > data$year=as.factor(data$year) > ferg=data[data$wtrbody=="Ferguson",c(1:12)] > library(lattice) > > strip.background=trellis.par.get("strip.background") > trellis.par.set(strip.background = list(col = grey(7:1/8))) > > histogram(~fl|year, data=ferg, as.table=T, type="count", > ? ? ? ?col='dark grey',layout=c(3,5),lwd=2, lty=1, > ? ? ? ?xlab=list("Fork Length (mm)", cex=1.4,font=2), > ? ? ? ?breaks=seq(from=300,to=900,by=25), > ? ? ? ?ylab=list("Frequency",cex=1.4,font=2), > ? ? ? ?scales=list(font=2,cex=1.1, tck=c(1,0), alternating=1, > ? ? ? ?y=list(relation="free",tick.number=3)), > ? ? ? ?par.strip.text=list(cex=1.2),font=2, > ? ? ? ?aspect=0.6) > > -- > View this message in context: http://r.789695.n4.nabble.com/Arrangement-of-Lattice-Histograms-Top-to-bottom-and-then-left-to-right-tp3428825p3428825.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. >-- "Men by nature long to get on to the ultimate truths, and will often be impatient with elementary studies or fight shy of them. If it were possible to reach the ultimate truths without the elementary studies usually prefixed to them, these would not be preparatory studies but superfluous diversions." -- Maimonides (1135-1204) Bert Gunter Genentech Nonclinical Biostatistics
Les
2011-Apr-05 20:45 UTC
[R] Arrangement of Lattice Histograms - Top to bottom and then left to right?
Thank you. The help is much appreciated. Les -- View this message in context: http://r.789695.n4.nabble.com/Arrangement-of-Lattice-Histograms-Top-to-bottom-and-then-left-to-right-tp3428825p3429123.html Sent from the R help mailing list archive at Nabble.com.