2016-07-05 13 views
0

私は20万以上の値を持つ大きなデータを持っています。プライバシーとコードの再現性のために、私はmydataを使用して置き換えます。凡例パッケージのfitdistrplusでの凡例R

set.seed(1234) 
mydata <- rlnorm(28000000,3.14,1.3) 

は、私はパッケージfitdistrplusで機能fitdistを選びだしているので、知られているディストリビューションは、最高のmydataに合わせた見つけたいです。

library(fitdistrplus) 
fit.lnorm <- fitdist(mydata,"lnorm") 
fit.weibull <- fitdist(mydata, "weibull") 
fit.gamma <- fitdist(mydata, "gamma", lower = c(0, 0)) 
fit.exp <- fitdist(mydata,"exp") 

はその後、私は私が最高のフィット分布を選択するためP-Pのプロットを描画するppcomp関数を使用します。

library(RColorBrewer) 
tiff("./pplot.tiff",res = 300,compression = "lzw",height = 6,width = 10,units = "in",pointsize = 12) 
ppcomp(list(fit.lnorm,fit.weibull, fit.gamma,fit.exp), fitcol = brewer.pal(9,"Set1")[1:4],legendtext = c("lnorm","weibull", "gamma","exp")) 
dev.off() 

pplot は絶対に、対数正規最高mydata収まるが、プロットのlegendを見て、異なる色のライン注釈が欠落している、唯一のテキスト注釈のショー、私は何をすべきでしょうか?

私はいくつかの値を持つデータセットを試してみました。大きなデータが問題につながります。私は伝説を完璧にするために何をすべきですか?

+0

'ppcomp'の' legend'コマンドに問題があり、おそらく 'lty'を指定する必要があります。 –

+0

@RichardTelfordええ、あなたは正しいのですか? –

答えて

0

多くの機能に関する質問はfix(function)で行うことができ、このようにして機能の仕組みを知ることができました。

fix(ppcomp)

そして、私は伝説に関するいくつかのコードを見つけ、

if (addlegend) { 
    if (missing(legendtext)) 
     legendtext <- paste("fit", 1:nft) 
    if (!largedata) 
     legend(x = xlegend, y = ylegend, bty = "n", legend = legendtext, 
     pch = fitpch, col = fitcol, ...) 
    else legend(x = xlegend, y = ylegend, bty = "n", legend = legendtext, 
     col = fitcol, ...) 
    } 

はその後、私は伝説にlty=1を追加し、それが動作します。