将 abline 添加到 xyplot(半对数)
adding abline to the xyplot (Semi-log)
我正在尝试在 xyplot 上添加 abline,y 轴在对数刻度上。我可以添加
当 y 不是对数刻度时使用 abline 行,但当 y 是对数刻度时它不起作用。
有什么建议吗!
谢谢!
library(lattice)
y <- c(2,10,25,70)
x <- c(0.2,0.3,0.5,1)
xyplot(y~x,
type='b',
scales=list(y=list(log=TRUE)),
panel = function(x, y) {
panel.xyplot(x, y)
panel.abline(h=8.8)
}
)
奇怪的是 lattice 没有正确处理 abline
的对数刻度。但是如果你对 lattice 进行计算,它似乎有效:
library(lattice)
y <- c(2,10,25,70)
x <- c(0.2,0.3,0.5,1)
xyplot(y~x,
type='b',
scales=list(y=list(log=T)),
panel = function(x, y) {
panel.xyplot(x, y)
panel.abline(h=log(8.8,10))
}
)
我正在尝试在 xyplot 上添加 abline,y 轴在对数刻度上。我可以添加 当 y 不是对数刻度时使用 abline 行,但当 y 是对数刻度时它不起作用。
有什么建议吗!
谢谢!
library(lattice)
y <- c(2,10,25,70)
x <- c(0.2,0.3,0.5,1)
xyplot(y~x,
type='b',
scales=list(y=list(log=TRUE)),
panel = function(x, y) {
panel.xyplot(x, y)
panel.abline(h=8.8)
}
)
奇怪的是 lattice 没有正确处理 abline
的对数刻度。但是如果你对 lattice 进行计算,它似乎有效:
library(lattice)
y <- c(2,10,25,70)
x <- c(0.2,0.3,0.5,1)
xyplot(y~x,
type='b',
scales=list(y=list(log=T)),
panel = function(x, y) {
panel.xyplot(x, y)
panel.abline(h=log(8.8,10))
}
)