Привет, я пытаюсь выделить значения выше 35 градусов по Цельсию красными точками и добавить месяцы, а также год к оси x. Правда, я изменил этот скрипт. Я новичок в R и был бы очень признателен за помощь. Также подойдет еще один пакет.
вот пример данных и кода.
Date reference shade sun
2010-03-01 NA 50.6221 53.3561
2010-03-02 NA 38.1599 40.3847
2010-03-03 NA 34.8627 38.3919
2010-03-04 NA 33.4927 35.0268
2011-04-22 NA 38.2654 45.972
2011-04-23 NA 38.0786 37.2561
2013-07-18 13.7 13.7 13.7
2013-07-19 18.7 19.1 18.7
2014-05-26 20.6 20.7 23.7
2014-05-27 21.6 22.2 24.6
2014-05-28 17.1 17.7 22.1
require(lattice)
require(RColorBrewer)
colset <- brewer.pal(3, "Set1")
trellis.device(device="pdf", file="nestbox_temp_profiles.pdf", height=11,
width=7.5, color=TRUE)
lab.reference <- "Reference Area"
lab.shade <- "Shaded Nest-boxes"
lab.sun <- "Sun Exposed Nest-boxes"
my.strip <- function(which.given, which.panel, ...) {
strip.labels <- c(lab.shade, lab.sun, lab.reference)
panel.rect(0, 0, 1, 1, col="#ffe5cc", border=1)
panel.text(x=0.5, y=0.5, adj=c(0.5, 0.55), cex=0.95,
lab=strip.labels[which.panel[which.given]])
} #--Custom strip function:
Nestemp$Date <- strptime(Nestemp$Date, format="%Y-%m-%d")#--Define X axis date range:
xlim <- range(Nestemp$Date)
d <- seq(from=as.Date("2010-03-01"), to=as.Date("2015-03-01"), by=365/4) #--Define annual quarters for plot grid line markers:
col.raw <- "#377EB8"
col.lm <- "red"
plot1<-xyplot(sun + shade + reference ~ Date, data=Nestemp,
scales=list(y="free", rot=0),
strip=my.strip, outer=TRUE, layout=c(1, 3, 1), ylab="Temperature (celsius)", xlab="",
panel=function(x, y, groups=groups) {panel.grid(h=0, v=0) panel.abline(v=d, col="grey90") panel.xyplot(x, y, ..., type="p", col=col.raw, lwd=0.8) panel.abline(h=35, lty=2, col="red", lwd=1)},
key=list(text=list(c("Nestbox Temperature", "Threshold 35 degrees celsius")),
title="Daily Maximum Nest box Temperature",
col=c(col.raw, col.lm), lty=c(1, 2),
columns=2, cex=0.95,
lines=TRUE),)
plot1
dev.off()