And the NaN alternative for vertical mirroring is:
plot([x; NaN; x], [y; NaN; -y], c=:blue)
And the NaN alternative for vertical mirroring is:
plot([x; NaN; x], [y; NaN; -y], c=:blue)
@rafael.guerra, I love seeing all the creative solutions you post, but I think for the OP here, it needed to be simplified beyond all expectations , so I cut to the shortest, simplest possible solution. I’ll use your NaN trick myself.
True, simplicity is king, but it is good to provide options that might be useful later.
I tried you method but it comes out as error saying Error: syntax: invalid keyword argument name “-(ylims)” around untitled-2:57. What am i doing wrong though.
function f(x; θ=15*pi/180)
if (x>-R1*sin(θ)) && (x<R1*sin(θ))
(R_throat+R1*(1-cos(asin(x/R1))))
elseif (x>R1*sind(θ))
(m*x+Y0)
end
end
using Plots
x=range(0, Xe, length=100)
y=m .* x .+Y0
plot((x,f.(x, θ=15*pi/180)), ylims=(0,0.75), color="blue")
plot!((x,f.(x, θ=15*pi/180)), -ylims=(0,0.75), color="blue")
You’re not doing the same. Note the absence of ylims above. Try exactly what I showed and then after you see it is working you can add extra niceties such as colors and axis limits. Keep your definition of f
and x
and using Plots
, but replace the rest with my code.
I see I thought that u can directly put the niceties on it and its looking better but how do I put the niceties to apply to the made plot?
function f(x; θ=15*pi/180)
if (x>-R1*sin(θ)) && (x<R1*sin(θ))
(R_throat+R1*(1-cos(asin(x/R1))))
elseif (x>R1*sind(θ))
(m*x+Y0)
end
end
using Plots
x=range(0, Xe, length=100)
y=m .* x .+Y0
plot(x,y)
plot!(x,-y)
plot(x, y, color="blue")
plot!(x, -y, ylims=(-0.75,0.75), color="blue")
https://docs.juliaplots.org/latest/tutorial/#Plot-Attributes
https://docs.juliaplots.org/latest/generated/attributes_axis/
https://docs.juliaplots.org/latest/generated/attributes_series/
Im trying to make the small curve at the start of the line but unfortunately its not doing anything btw tq for the link I learn some new cool stuff
function f(x; θ=15*pi/180)
if (x>-R1*sin(θ)) && (x<R1*sin(θ))
(R_throat+R1*(1-cos(asin(x/R1))))
elseif (x>R1*sind(θ))
(m*x+Y0)
end
end
using Plots
x=range(0, Xe, length=100)
y=m .* x .+Y0
plot((x,f.(x, θ=15*pi/180)), y, color="blue")
plot!((x,f.(x, θ=15*pi/180)), -y, ylims=(-0.75,0.75), color="blue")
title!("Rocket nozzle")
xlabel!("x")
ylabel!("y")