Skip to content

Commit f5a892b

Browse files
committed
Improve the legend of the Cullen and Frey plot, as suggested in the issue #24
1 parent d6eeb4c commit f5a892b

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

Diff for: R/descdist.R

+25-22
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,24 @@ descdist <- function(data, discrete = FALSE, boot = NULL, method = "unbiased",
141141
y<-kurtmax-(es2^4+2*es2^3+3*es2^2-3)
142142
lines(s2,y,lty=3)
143143

144-
legend(xmax*0.2,ymax*1.03,pch=obs.pch,legend="Observation",bty="n",cex=0.8,pt.cex=1.2,col=obs.col)
144+
145+
legend(xmax*0.55, ymax*1.03,legend="Theoretical",bty="n",cex=0.8)
146+
legend(xmax*0.6, ymax*0.98,pch=8,legend="normal",bty="n",cex=0.8)
147+
legend(xmax*0.6, ymax*0.94,pch=2,legend="uniform",bty="n",cex=0.8)
148+
legend(xmax*0.6, ymax*0.90,pch=7,legend="exponential",bty="n",cex=0.8)
149+
legend(xmax*0.6, ymax*0.86,pch=3,legend="logistic",bty="n",cex=0.8)
150+
legend(xmax*0.6, ymax*0.82,fill="grey80",legend="beta",bty="n",cex=0.8)
151+
legend(xmax*0.6, ymax*0.78,lty=3,legend="lognormal",bty="n",cex=0.8)
152+
legend(xmax*0.6, ymax*0.74,lty=2,legend="gamma",bty="n",cex=0.8)
153+
legend(xmax*0.6, ymax*0.69,legend=c("(Weibull is close to gamma and lognormal)"), bty="n",cex=0.6)
154+
155+
legend(xmax*0.55, ymax*0.64,legend="Empirical",bty="n",cex=0.8)
156+
legend(xmax*0.6, ymax*0.60,pch=obs.pch,legend="data",bty="n",cex=0.8,pt.cex=1.2,col=obs.col)
145157
if (!is.null(boot)) {
146-
legend(xmax*0.2,ymax*0.98,pch=1,legend="bootstrapped values",
147-
bty="n",cex=0.8,col=boot.col)
158+
legend(xmax*0.6, ymax*0.56,pch=1,legend="bootstrap", bty="n",cex=0.8,col=boot.col)
148159
}
149-
legend(xmax*0.55,ymax*1.03,legend="Theoretical distributions",bty="n",cex=0.8)
150-
legend(xmax*0.6,0.98*ymax,pch=8,legend="normal",bty="n",cex=0.8)
151-
legend(xmax*0.6,0.94*ymax,pch=2,legend="uniform",bty="n",cex=0.8)
152-
legend(xmax*0.6,0.90*ymax,pch=7,legend="exponential",bty="n",cex=0.8)
153-
legend(xmax*0.6,0.86*ymax,pch=3,legend="logistic",bty="n",cex=0.8)
154-
legend(xmax*0.6,0.82*ymax,fill="grey80",legend="beta",bty="n",cex=0.8)
155-
legend(xmax*0.6,0.78*ymax,lty=3,legend="lognormal",bty="n",cex=0.8)
156-
legend(xmax*0.6,0.74*ymax,lty=2,legend="gamma",bty="n",cex=0.8)
157-
legend(xmax*0.58,0.69*ymax,legend=c("(Weibull is close to gamma and lognormal)"),
158-
bty="n",cex=0.6)
159160
}
160-
else {
161+
else {
161162
# negbin dist
162163
p<-exp(-10)
163164
lr<-seq(-100,100,0.1)
@@ -172,16 +173,18 @@ descdist <- function(data, discrete = FALSE, boot = NULL, method = "unbiased",
172173
s2<-c(s2a,s2b)
173174
y<-c(ya,yb)
174175
polygon(s2,y,col="grey80",border="grey80")
175-
legend(xmax*0.2,ymax*1.03,pch=obs.pch,legend="Observation",bty="n",cex=0.8,pt.cex=1.2, col = obs.col)
176+
177+
legend(xmax*0.55,ymax*1.03,legend="Theoretical",bty="n",cex=0.8)
178+
legend(xmax*0.6, ymax*0.98,pch=8,legend="normal",bty="n",cex=0.8)
179+
legend(xmax*0.6, ymax*0.94,fill="grey80",legend="negative binomial",bty="n",cex=0.8)
180+
legend(xmax*0.6, ymax*0.90,lty=2,legend="Poisson",bty="n",cex=0.8)
181+
182+
legend(xmax*0.55,ymax*0.85,legend="Empirical",bty="n",cex=0.8)
183+
legend(xmax*0.6, ymax*0.81,pch=obs.pch,legend="data",bty="n",cex=0.8,pt.cex=1.2, col = obs.col)
176184
if (!is.null(boot)) {
177-
legend(xmax*0.2,ymax*0.98,pch=1,legend="bootstrapped values",
178-
bty="n",cex=0.8,col=boot.col)
185+
legend(xmax*0.6, ymax*0.77,pch=1,legend="bootstrap",bty="n",cex=0.8,col=boot.col)
179186
}
180-
legend(xmax*0.55,ymax*1.03,legend="Theoretical distributions",bty="n",cex=0.8)
181-
legend(xmax*0.6,0.98*ymax,pch=8,legend="normal",bty="n",cex=0.8)
182-
legend(xmax*0.6,0.94*ymax,fill="grey80",legend="negative binomial",
183-
bty="n",cex=0.8)
184-
legend(xmax*0.6,0.90*ymax,lty=2,legend="Poisson",bty="n",cex=0.8)
187+
185188
# poisson dist
186189
llambda<-seq(-100,100,0.1)
187190
lambda<-exp(llambda)

Diff for: man/descdist.Rd

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ descdist(x1,boot=500)
109109
# with changing of default colors and plotting character for observed point
110110
#
111111
descdist(rbeta(100,shape1=0.05,shape2=1),boot=500,
112-
obs.col="blue", obs.pch = 15, boot.col="yellow")
112+
obs.col="blue", obs.pch = 15, boot.col="darkgreen")
113113
114114
# (3) Description of a sample from a gamma distribution
115115
# with uncertainty on skewness and kurtosis estimated by bootstrap

0 commit comments

Comments
 (0)