我正在尝试使用ggplot2创建一个日志正常y比例的性能图表.不幸的是,我不能像基本情节函数那样产生好的滴答声.
这是我的例子:
library(ggplot2)
library(scales)
# fix RNG
set.seed(seed = 1)
# simulate returns
y=rnorm(999, 0.02, 0.2)
# M$Y are the cummulative returns (like an index)
M = data.frame(X = 1:1000, Y=100)
for (i in 2:1000)
M[i, "Y"] = M[i-1, "Y"] * (1 + y[i-1])
ggplot(M, aes(x = X, y = Y)) + geom_line() + scale_y_continuous(trans = log_trans())
Run Code Online (Sandbox Code Playgroud)
产生难看的蜱:
我也尝试过:
ggplot(M, aes(x = X, y = Y)) + geom_line() +
scale_y_continuous(trans = log_trans(), breaks = pretty_breaks())
Run Code Online (Sandbox Code Playgroud)
如何获得与默认绘图函数相同的中断/刻度:
plot(M, type = "l", …
Run Code Online (Sandbox Code Playgroud)