Dear list,
I've been learning how to make a 2x2 paneled dotplot in lattice without any
previous experience using lattice.
my code thusfar is:
nut<-read.table("/Users/colinwahl/Desktop/nutsimp_noerror.csv",
T, sep",")
attach(nut)
nut1<-data.frame(Nitrate, Total_Nitrogen, Phosphate, Total_Phosphorus)
nut1<-as.matrix(nut1)
rownames(nut1)<-group
ylimlist=list(c(0,10), c(0,10), c(0,0.25), c(0,0.25))
dotplot(nut1, groups=FALSE, horizontal=FALSE, scales =
list(relation='free'
), ylim=ylimlist, ylab="Nutrient Concentration (mg/L)")
I have two issues currently: eliminating y and x tick labels between panels,
and creating error bars.
1st issue:
Figure 4.1 in Deepayan Sarkar's book creates a simple 2x2 dotplot that only
has x and y axis tick labels on the bottom and left margins of the whole
figure:
dotplot(VADeaths, groups = FALSE)
When I add scales = list(relation='free') to customize y ranges with
ylim=ylimlist, each panel has its own y and x axis tick labels. I would like
the figure panels to fit to gether like this simple figure.
2nd issue:
I'd like to create standard error bars for each point. The most direct
option I've observed is from:
http://www.unc.edu/courses/2010fall/ecol/563/001/docs/solutions/assign2.htm
It seems to use the following panel function to create 95% conf. intervals:
panel=function(x,y) {
panel.grid(v=0, h=-6, lty=3)
panel.segments(new.data$lower95, as.numeric(y), new.data$upper95,
as.numeric(y), lty=1, col=1)
panel.segments(new.data$lower50, as.numeric(y), new.data$upper50,
as.numeric(y), lty=1, lwd=4, col='grey60')
panel.xyplot(x, y, pch=16, cex=1.2, col='white')
panel.xyplot(x, y, pch=1, cex=1.1, col='black')
panel.abline(v=0, col=2, lty=2)
}
I tried to adapt this to my data resulting in the following code:
dotplot(nut1, groups=FALSE, horizontal=FALSE, scales =
list(relation='free'
), ylim=ylimlist, ylab="Nutrient Concentration (mg/L)",
panel=function(x,y) {
panel.segments(nut$N.upper, as.numeric(y), nut$N.lower, as.numeric(y), lty=1
, col=1)
})
I have no experience with panel functions and would very much appreciate
advice.
Thank you,
Colin Wahl
Graduate Student
Dept. of Biology
Western Washington University
[[alternative HTML version deleted]]