How to get rid of the straight line?

Hi guys this may sound weird but Im trying to plot my graph without the straight line that connecting to the curve in it, unfortunately I dont know how from my own equation. :joy: so that the result at the end i will get a smooth curve.

Molar_mass=27
P0=15
P0_pa=1519875
p_amb=101325
R=8314
Rspec=R/Molar_mass
Cp=2112
Cv=Cp-Rspec
γ=Cp/Cv
Pe=0.372
Thrust_exit=450000
T0=2500
Te=(Pe/P0)^((γ-1)/γ)*T0
T_Throat=T0*(2/(γ+1))
Me=sqrt((2/(γ-1))*((P0/Pe)^((γ-1)/γ)-1))
Ae=sqrt(γ*Rspec*Te)
Ue=Me*Ae
ṁ=Thrust_exit/Ue
ρ0=(Molar_mass*P0_pa)/(R*T0)
ρ_Throat=ρ0*(2/(γ+1))^(γ/(γ-1))
A_star=ṁ/(ρ0*((2/(γ+1))^(1/(γ-1)))*sqrt(γ*Rspec*(2/(γ+1))*T0))
A_ratio=A_star*sqrt((1/Me^2)*((2/(γ+1))*(1+((γ-1)/2)*(Me^2)))^((γ+1)/(γ-1)))
a_star=sqrt(γ*Rspec*T0*(2/(γ+1)))

θ=30*pi/180
R_throat=sqrt(A_star/pi)
R1=1.5*R_throat
ϵ=A_ratio/A_star
R0=sqrt(ϵ)*R_throat
Rm=R_throat+R1*(1-cos(θ))
λ=(1+cos(θ))/2 
Lm=(R0-R_throat+R1*(cos(θ)-1))/tan(θ)
Lcc=(R_throat*(sqrt(ϵ)-1)+R1*(cos(θ)-1))/tan(θ)+(R1*sin(θ))
L2=Lcc-Lm
Xm=R1*sin(θ)
Ym=R_throat+R1*(1-cos(θ))
X_inlet=Xm+Lm
Y_inlet=R0+R1*(1-cos(θ))
m=(Y_inlet-Ym)/(X_inlet-Xm)
Y02=Ym

using Plots

function f(x; θ=30pi/180)
    
    global Y02, R1, R_throat, m

    if -R1*sin(θ) < x < R1*sin(θ)

        return R_throat + R1 * (1 - cos(asin(x/R1)))

    else
        return Y02

    end
end

x2 = range(0, X_inlet, length=50)
plot(-x2, f.(x2), color=:blue, label=missing)
plot!(-x2, -f.(x2), color=:blue, label=missing)
plot!(ylims=(-0.75,0.75))

If the values on the line are equal, and occur in the same place in the vectors, it would be easy to do something like keep_idx = y_line .!= y, where y_line is the value associated with the line, and y = f.(x2). You can use keep_idx to filter out the line.

The line is still there eventhough i put the keep_idx , what could i had done wrong

x2 = range(0, X_inlet, length=50)
y=f.(x2)
keep_idx=Y02 .!=y
plot(-x2, f.(x2), color=:blue, label=missing)
plot!(-x2, -f.(x2), color=:blue, label=missing)
plot!(ylims=(-0.75,0.75))

You still need to use keep_idx remove elements from x2 and y. Each element in keep_idx is a boolean, which will keep a value if true and will exclude a value if false. So what you need to do is index x2 and y like so:

x2 = range(0, X_inlet, length=50)
y=f.(x2)
keep_idx=Y02 .!=y
plot(-x2[keep_idx], y[keep_idx], color=:blue, label=missing)
plot!(-x2[keep_idx], -y[keep_idx], color=:blue, label=missing)
plot!(ylims=(-0.75,0.75))
1 Like

I have try and put in your code its turns out like this.

You code does not provide the values of A_star and A_ratio, which makes it difficult for testing your code (Please read: make it easier to help you)

sorry just edited my post

Now Molar_mass is not defined. Please check before posting that a MWE is actually working, you will get much quicker help.

just edited it forgot to copy the molar mass.

This is what I get with your code and which does not correspond to your first plot, so you probably changed some values

Anyway, when I apply the solution How to get rid of the straight line? - #4 by Christopher_Fisher

x2 = range(0, X_inlet, length=50)
y=f.(x2)
keep_idx=Y02 .!=y
plot(-x2[keep_idx], y[keep_idx], color=:blue, label=missing)
plot!(-x2[keep_idx], -y[keep_idx], color=:blue, label=missing)
plot!(ylims=(-0.75,0.75))

it does exactly what you asked for, taking away the constant line.

I meant like just deleting the whole line so will get a graph look like this

Because then i got to figure out how to do the next curve replacing the straigh line

Still not sure what you actually ask. If it is just a graphic windows problem, either add your next curve with plot! and the axes will adapt or force the axes with plot!(xlims=(-.7,0)) for example.