# How to get rid of the straight line?

**URL:** https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646
**Category:** New to Julia
**Tags:** question, plotting
**Created:** [January 10, 2024, 9:48pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646 "2024-01-10T21:48:31Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 10, 2024, 9:48pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/1 "2024-01-10T21:48:31Z")

</div>

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. 😂 so that the result at the end i will get a smooth curve.

```julia
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
ṁ=Thrust_exit/Ue
ρ0=(Molar_mass*P0_pa)/(R*T0)
ρ_Throat=ρ0*(2/(γ+1))^(γ/(γ-1))
A_star=ṁ/(ρ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))

```

 ![plot_118_page-0001](https://global.discourse-cdn.com/julialang/original/3X/e/5/e5217e3c6c169192e00b640d8862d5ff02bf026a.jpeg)

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [January 11, 2024, 12:05am UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/2 "2024-01-11T00:05:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 11, 2024, 12:37am UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/3 "2024-01-11T00:37:45Z")

</div>

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

```julia
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))

```

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [January 11, 2024, 1:54pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/4 "2024-01-11T13:54:45Z")

</div>

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:

```julia
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))

```

---

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 11, 2024, 2:27pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/5 "2024-01-11T14:27:59Z")

</div>

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

 ![plot_34_page-0001](https://global.discourse-cdn.com/julialang/original/3X/3/4/3428cbbca6de5dcf16205f1866a744fd2ef451ef.jpeg)

---

<div class="post-metadata">

### Author: ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)
#### Post date: [January 11, 2024, 2:40pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/6 "2024-01-11T14:40:46Z")

</div>

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](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757))

---

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 11, 2024, 2:55pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/7 "2024-01-11T14:55:51Z")

</div>

sorry just edited my [post](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646)

---

<div class="post-metadata">

### Author: ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)
#### Post date: [January 11, 2024, 2:58pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/8 "2024-01-11T14:58:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 11, 2024, 3:12pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/9 "2024-01-11T15:12:19Z")

</div>

just edited it forgot to copy the molar mass.

---

<div class="post-metadata">

### Author: ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)
#### Post date: [January 11, 2024, 3:18pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/10 "2024-01-11T15:18:41Z")

</div>

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

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/9/99a1949a009273a76fb7fd64a56aa35e49ad69d8.png)

Anyway, when I apply the solution [How to get rid of the straight line? - #4 by Christopher\_Fisher](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/4)

```julia
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.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/9/39152986732ce171a78bf465705fe19f4a710e72.png)

---

<div class="post-metadata">

### Author: ![kim1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim1/32/205937_2.png) [@kim1](https://discourse.julialang.org/u/kim1)
#### Post date: [January 11, 2024, 4:00pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/11 "2024-01-11T16:00:56Z")

</div>

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

 ![like this](https://global.discourse-cdn.com/julialang/original/3X/3/b/3b41c0d7c6feebd198bf291d18aca5815ce34299.png)

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

 ![ideal graph](https://global.discourse-cdn.com/julialang/original/3X/3/3/33834b9be470b5d357096084e583a65f9f69e181.png)

---

<div class="post-metadata">

### Author: ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)
#### Post date: [January 11, 2024, 6:54pm UTC](https://discourse.julialang.org/t/how-to-get-rid-of-the-straight-line/108646/12 "2024-01-11T18:54:37Z")

</div>

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.
