set.seed(2)
x = c(1, rnorm(100, 15, 5))
y = c(1, rnorm(100, 15, 5))
plot(x, y, log = "xy")
plot(log(x), log(y))
当我在log
函数中使用plot()
- 参数以及首先变换变量时,有什么区别,然后绘制它们。 Hier是plot(x, y, log = "xy")
的情节。
有人能解释一下log
- 论证到底是做什么的吗?谢谢。
答案 0 :(得分:2)
对于日志图,您不必修改数据。这只是一个显示问题,因此您可以进一步处理您的数据。就像例子一样:
set.seed(2)
x = c(1, rnorm(100, 15, 50))
y = c(1, rnorm(100, 15, 50))
plot(x, y, col = "black",
log = "xy", xaxt = "n", yaxt = "n",)
# Labels...
at.y <- outer(1:9, 10^(log10(1):log10(100)))
lab.y <- ifelse(log10(at.y) %% 1 == 0,
sapply(at.y, function(i)
as.expression(bquote(10^.(log10(i))))
), NA)
axis(2, at = at.y, labels = lab.y, las = 1)
at.x <- outer(1:9, 10^(0:log10(100)))
lab.x <- ifelse(log10(at.x) %% 1 == 0,
sapply(at.x, function(i)
as.expression(bquote(10^.(log10(i))))
), NA)
axis(1, at = at.x, labels = lab.x, las = 1)
grid (NULL,NULL, lty = 6, col = "cornsilk2")
结果: