[R] show 0 at y axis in xyplot lattice
Bert Gunter
bgunter.4567 at gmail.com
Tue Sep 12 00:50:29 CEST 2017
Not reproducible, as we have neither "example.csv" nor "Date" .
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Sep 11, 2017 at 2:38 PM, Maria Lathouri <mlathouri at yahoo.gr> wrote:
> Dear Bert and all,
>
> I am really sorry. This is the full code:
>
> dat<-read.csv("example.csv")
> attach(dat)
>
> sdate<-as.Date(Date, format="%Y-%m-%d")
>
> #change the colour of the strip background
> my.settings <- canonical.theme(color=FALSE)
> my.settings[['strip.background']]$col <- "blue"
>
> dat_key <- list(space="right",
> lines = list(type = c("b", "b", "b"), pch=c(22, 21, 22),
> col = c("red", "black", "red"),
> fill=c("red", "black", "red"), lwd=1,
> lty=c(2, 1, 2)),
> text = list((c("upper se", (expression(paste(Zn^paste(2,"+")))),
> "lower se"))))
>
> 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, ...)
> }
> )
>
> Hope this helps.
>
> Kind regards,
> Maria
>
>
> Στις 10:15 μ.μ. Δευτέρα, 11 Σεπτεμβρίου 2017, ο/η Bert Gunter <
> bgunter.4567 at gmail.com> έγραψε:
>
>
> 1. Not reproducible since my.settings, dat_key, sdate not provided.
>
> 2. Why did you not try something like ylim = c(-5,80) ?
>
>
> Cheers,
> Bert
>
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
> On Mon, Sep 11, 2017 at 12:33 PM, Maria Lathouri via R-help <
> r-help at r-project.org> wrote:
>
> 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
> ______________________________ ________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/ listinfo/r-help
> <https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html <http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list