[R] panel.rect and log scale in lattice plot
Garbade, Sven
Sven@G@rb@de @end|ng |rom med@un|-he|de|berg@de
Wed Mar 23 10:38:34 CET 2022
Dear all,
I posted this on Stack Overflow, but there is no response, so I try it here again.
I'm wondering about how to draw a highlighted rectangle with log y-axis in a trellis/lattice plot. My idea was to use panel.rect(), which works without a log scale:
library(lattice)
set.seed(1)
y <- runif(100, min=1, max=1000)
x <- seq_along(y)
xyplot(y ~ x,
panel=function(x,y,...) {
cpl <- current.panel.limits()
panel.rect(xleft=cpl$xlim[1], ybottom=10,
xright=cpl$xlim[2], ytop=500,
fill="lightgray", border="lightgray", alpha=.6)
panel.xyplot(x,y,...)
},
scales=list(y=list(log=FALSE))
)
However, when log=TRUE, the rectangle disappears.
Are there any ideas? Thanks, Sven
<https://mail.med.uni-heidelberg.de/questions/tagged/,DanaInfo=stackoverflow.com,SSL+r>
[[alternative HTML version deleted]]
More information about the R-help
mailing list