I am trying to draw a curve and showing it with a single line . Here I face the issue that instead of joining with a single line it shows many

46 views Asked by At

I want to join this curve with single line. But theses points are merging with one another

\lamda =1.8268470
beta= 0.6806978  
delta=3.8760680


y<-c(2.01, 6.32, 3.52, 2.15, 5.42, 2.04, 2.77, 2.26, 1.95, 1.00, 2.45, 0.74, 0.98, 1.27, 2.77, 3.68, 1.18, 1.09, 1.60, 0.57,3.33, 0.91, 7.14, 2.08, 3.85, 1.99, 7.76, 2.52, 1.57, 4.67, 4.22, 1.92, 1.59, 4.08, 2.02, 0.84, 6.85, 2.18, 2.04, 1.05,2.91, 1.37, 2.43, 2.28, 3.74, 1.30, 1.59, 1.83, 3.85, 6.30, 4.83, 0.50, 3.40, 2.33, 4.25, 3.49, 2.12, 0.83, 0.54, 3.23,4.50, 0.71, 0.48, 2.30, 7.73)

G =(1+lamda *y)^(beta)
C = exp(1-G)
B=1-C
H=B^(delta)
M=(2^H)-1
g=(1+lamda*y)^(beta-1)
par(mar=c(3.1, 4.0, 0.3, 0.3))
h=lamda*beta*C*g*(2^H)*delta*((B)^(delta-1))*log(2)/(1-(2^H)+1)
plot(y,h,type="b",col="red", ylab="",main = NULL)
1

There are 1 answers

0
SamR On

Data frames are useful. Once it's in a data frame you can sort by y.

dat  <- data.frame(y, h)[order(y),]
plot(dat$y, dat$h, type="b",col="red", xlab = "y", ylab="h", lwd=2)

enter image description here

Alternatively, you could do:

plot(sort(y), h[order(y)], type="b",col="red", xlab = "y", ylab="h", lwd=2)