5
我試着通過stat_function()
在ggplot
疊加功能,但無法弄清楚我的錯誤對數正態密度。這個例子會產生一個好看的情節:疊加在ggplot和stat_function()
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()
所以這裏是我的希望很簡單的問題:我究竟做錯了什麼?我想這是一個非常簡單的問題,我只是不明白的答案 - 對不起。
我沒有得到一個desnsity如何爲負。 –
我覺得你的問題的一部分是'數= TRUE' –
@LucianoSelzer當然,你是對的 - 我認爲這將通過'登錄= TRUE'說法,但作爲埃裏克森證實有一個更簡單的方式工作;) – Seb