Dear all
I am trying to make a plot in xyplot lattice by groups. I would like to show
"0" in y axis but I don't want to be aligned with the x axis. I want to be a
little bit above.
I have tried many options but I don't get what I want. I also tried ylim=c(0,
80) but both 0 and 80 are fully aligned with the x-axis and the upper boundary
of the plot, respectively:
xyplot(upper.zn + Zn2 + lower.zn ~ sdate | Location, type="b", as.table=TRUE,
data=dat, pch=c(22, 21, 22), lty=c(2, 1, 2), ylim=c(0, 80),
index.cond=list(c(3, 1, 2)), ylab="Percent (%)",
par.strip.text=list(col="white", font=2, lines=1.5),
lattice.options = modifyList(lattice.options(),
list(skip.boundary.labels = 0)),
par.settings=my.settings, col=c("red", "black", "red"), fill=c("red",
"black", "red"),
key=dat_key, scales = list(x = list(at = sdate, labels = format(sdate,
"%b-%y"))), xlab="Date",
panel = function(x, y, ...) {
panel.grid(h = -1, v = 0, lwd=1, lty=3, col="grey")
panel.abline(v=sdate, lwd=1, lty=3, col="grey")
panel.xyplot(x, y, ...)
}
)
when I use the following, 80 is a bit lower than the upper boundary of the
plot, which is what I want, but 0 is not showing:
xyplot(upper.zn + Zn2 + lower.zn ~ sdate | Location, type="b", as.table=TRUE,
data=dat, pch=c(22, 21, 22), lty=c(2, 1, 2),
index.cond=list(c(3, 1, 2)), ylab="Percent (%)",
par.strip.text=list(col="white", font=2, lines=1.5),
lattice.options = modifyList(lattice.options(),
list(skip.boundary.labels = 0)),
par.settings=my.settings, col=c("red", "black", "red"), fill=c("red",
"black", "red"),
key=dat_key, scales = list(x = list(at = sdate, labels = format(sdate,
"%b-%y")), y=list(at=c(0, 20, 40, 60, 80))), xlab="Date",
panel = function(x, y, ...) {
panel.grid(h = -1, v = 0, lwd=1, lty=3, col="grey")
panel.abline(v=sdate, lwd=1, lty=3, col="grey")
panel.xyplot(x, y, ...)
}
)I have also attached a reproducible example in case you want to see
in more detail my data.
I would very much appreciate any suggestions on this.
Thank you in advance.
Kind regards,Maria
structure(list(Location = structure(c(3L, 2L, 1L, 3L, 2L, 1L,
3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L, 3L, 2L, 1L), .Label = c("downstream",
"spill", "upstream"), class = "factor"), Date = structure(c(1L,
1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L,
6L), .Label = c("2016-04-27", "2016-06-28", "2016-08-25", "2016-10-25",
"2016-12-21", "2017-02-20"), class = "factor"), Zn2 = c(29.92476703,
12.84040165, 22.496731, 23.98425342, 41.51335929, 15.51232289,
21.73037433, 13.42082139, 10.99209223, 20.8246236, 14.01283297,
15.677398, 28.1496556, 13.91586565, 13.02749294, 31.16736498,
12.47368407, 17.65740863), upper.zn = c(55.59799624, 22.0700594,
41.60901086, 45.60219163, 77.99892514, 26.94058693, 40.95851559,
22.96901479, 20.17470754, 40.60564483, 25.07031719, 30.42278408,
51.79389664, 23.94367855, 24.4693001, 55.5185782, 22.03829768,
33.23577364), lower.zn = c(13.91220671, 6.964933684, 11.73910885,
10.69063953, 20.14242582, 7.044781184, 10.35462038, 7.472893173,
5.32431795, 9.602007459, 7.830503865, 6.971944054, 14.38413938,
8.164688468, 5.826650446, 15.93821078, 6.725540245, 8.519928496
)), .Names = c("Location", "Date", "Zn2", "upper.zn", "lower.zn"
), class = "data.frame", row.names = c(NA, -18L))
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.