How to delete the number of lines plotted in the graph

I’m not sure of your experience level with the language, so pardon if some are pedantic, but I’ve got a couple of notes here that I hope might be helpful.

Your function f has inconsistent usage of sin vs sind; I think under the elseif condition you intended to use sin(θ). Also, the if/elseif conditions you provided can be cleaned up a bit. What happens if x == R1*sin(θ)? See the code block at the bottom of this post for a suggestion.

You’re referencing a few global variables that aren’t provided, and I can’t replicate your current result as-is. Specifically, R1, R_throat, m, Y0, and Xe aren’t defined here. In some cases, like in the REPL, Julia will run this function without issue; but in others like executing a source file directly you can get errors/warnings when trying to access globally-scoped variables from within a function without explicitly declaring them as global. Referencing globals from within a function has some drawbacks, especially in terms of performance, but sometimes it’s what you want to do.

You define a function f(x; θ=15*pi/180) which has a keyword argument θ with a default value 15pi/180. This means that any time you call simply f(x), it will by default have defined a variable θ = 15pi/180 inside. So, in your plot calls at the bottom there’s no real need to call f.(x, θ=15*pi/180)) since that’s already the default value; you could also just have written f.(x) here.

The Plots.jl package always felt slightly cryptic to me, so I’m not sure if putting your data in a tuple, i.e. (x, y) has any special meaning, but the syntax plot(x, y) where x and y are equal-length vectors of corresponding point values works just fine.

Keyword argument settings passed to plot are usually respected when the figure is modified by a plot! call, so no need to repeat the ylims settings. In fact, you can also make a plot! call with nothing but keyword arguments if you’d like to group those settings all at once.

using Plots

# Values of these globals not provided, so I'm just guessing for each
m = 0.2
R1 = 5.0
R_throat = 0.25
Xe = pi/2
Y0 = 0.25

function f(x; θ=15pi/180)
    # These names reference global-scope variables (defined above)
    global Y0, R1, R_throat, m

    if -R1*sin(θ) < x < R1*sin(θ)
        return R_throat + R1 * (1 - cos(asin(x/R1)))
    else
        return m * x + Y0
    end
end

# Plot f over a range of x's
xs = range(0, Xe, length=100)
plot(xs, f.(xs), color=:blue)
plot!(-xs, f.(xs), color=:red)
plot!(ylims=(0,0.75), legend=:bottomright)

image

Or, alternately, the plot could be constructed as:

xs = range(-Xe, Xe, length=100)
plot(xs, f.(abs.(xs)), color=:blue)
plot!(ylims=(0,0.75), legend=:bottomright)

image