linhas de densidade com legenda

Bom dia, caros membros Estou tendo dificuldade, vocês podem me ajudar a a transformar o gráfico abaixo em 4 linhas de densidade com legenda? x=c(3.42,4.01,4.04,4.26,4.10,5.61,4.90,3.67,5.30,5.05,4.44,3.50,4.09,5.05,4.40,3.99,3.86, 4.99,2.86,2.18,3.61,4.45,5.01,3.11,3.53,4.70,4.03,3.23,2.87,3.38,3.04,4.59,1.45,3.91,5.46,5.70, 3.33,3.38,5.43,3.33,4.37,3.83,3.45,5.74,3.64,3.23,4.32,2.91,4.69,4.04,3.10,3.29,4.04,3.41,4.57, 2.97,5.46,4.02,5.62,4.94,3.23,4.39,3.67,3.99,2.60,3.05,2.81,2.61,3.06,4.21,3.19,2.30,2.84,2.60, 4.32,2.55,3.23,3.66,3.26,3.90,4.60,3.99,3.42,4.53,3.20,3.46,3.19) hist(rexp(1000,1/min(x)),freq=FALSE) hist(rgamma(1000,shape=mean(x)^2,rate=mean(x)),freq=FALSE,add=TRUE) hist(rexp(1000,1/mean(x)),freq=FALSE,add=TRUE) hist(rexp(1000,1/max(x)),freq=FALSE,add=TRUE)

Seria isso? x=c(3.42,4.01,4.04,4.26,4.10,5.61,4.90,3.67,5.30,5.05,4.44,3.50,4.09,5.05,4.40,3.99,3.86, 4.99,2.86,2.18,3.61,4.45,5.01,3.11,3.53,4.70,4.03,3.23,2.87,3.38,3.04,4.59,1.45,3.91,5.46,5.70, 3.33,3.38,5.43,3.33,4.37,3.83,3.45,5.74,3.64,3.23,4.32,2.91,4.69,4.04,3.10,3.29,4.04,3.41,4.57, 2.97,5.46,4.02,5.62,4.94,3.23,4.39,3.67,3.99,2.60,3.05,2.81,2.61,3.06,4.21,3.19,2.30,2.84,2.60, 4.32,2.55,3.23,3.66,3.26,3.90,4.60,3.99,3.42,4.53,3.20,3.46,3.19) plot(density(rgamma(1000,shape=mean(x)^2)), col= 'orange', xlim= c(0, 40), ylim= c(0,.6)) lines(density(rexp(1000,1/min(x))),col= 'red', lty=2) lines(density(rexp(1000,1/mean(x))), col= 'blue', lty=3) lines(density(rexp(1000,1/max(x))), col= 'green', lty= 4) legend(30, .5, legend=c("Line 1", "Line 2", "Line 3", "Line 4"), col=c('orange',"red", "blue", 'green'), lty=1:4, cex=0.8) Daniel
On 5 Jun 2018, at 07:51, Alice Peres via R-br <r-br@listas.c3sl.ufpr.br> wrote:
x=c(3.42,4.01,4.04,4.26,4.10,5.61,4.90,3.67,5.30,5.05,4.44,3.50,4.09,5.05,4.40,3.99,3.86, 4.99,2.86,2.18,3.61,4.45,5.01,3.11,3.53,4.70,4.03,3.23,2.87,3.38,3.04,4.59,1.45,3.91,5.46,5.70, 3.33,3.38,5.43,3.33,4.37,3.83,3.45,5.74,3.64,3.23,4.32,2.91,4.69,4.04,3.10,3.29,4.04,3.41,4.57, 2.97,5.46,4.02,5.62,4.94,3.23,4.39,3.67,3.99,2.60,3.05,2.81,2.61,3.06,4.21,3.19,2.30,2.84,2.60, 4.32,2.55,3.23,3.66,3.26,3.90,4.60,3.99,3.42,4.53,3.20,3.46,3.19)
hist(rexp(1000,1/min(x)),freq=FALSE)
hist(rgamma(1000,shape=mean(x)^2,rate=mean(x)),freq=FALSE,add=TRUE)
hist(rexp(1000,1/mean(x)),freq=FALSE,add=TRUE)
hist(rexp(1000,1/max(x)),freq=FALSE,add=TRUE)
participantes (2)
-
Alice Peres
-
Daniel Guimarães Tiezzi