我试图通过叠加功能stat_function()
在ggplot
,但不能找出我的错误。 这个例子会产生一个好看的情节:
data <- data.frame(x=rt(10000, df=7))
ggplot(data=data, aes(x=x)) + geom_histogram(aes(y = ..density..)) +
stat_function(fun =dnorm, size=1, color='gray', args=list()) +
opts(title="Histogram of interest rate changes") + theme_bw()
但是当我尝试叠加对数正态密度预计不工作(或者我应该说预期这不起作用):
data <- data.frame(x=rf(10000, df1=7, df2=120))
ggplot(data=data, aes(x=x)) + geom_histogram(aes(y = ..density..)) +
stat_function(fun =dnorm, size=1, color='gray', args=list(log=TRUE)) +
opts(title="Histogram of interest rate changes") + theme_bw()
所以这里我希望简单的问题:我究竟做错了什么? 我想这是一个非常简单的问题,我只是不明白的答案 - 对不起。