# How to plot a mirror graph from the one created

**URL:** <https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [January 5, 2024, 4:25pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394 "2024-01-05T16:25:09Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 8, 2024, 8:20pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/21 "2024-01-08T20:20:30Z")

</div>

And the NaN alternative for vertical mirroring is:

```julia
plot([x; NaN; x], [y; NaN; -y], c=:blue)

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [January 8, 2024, 8:25pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/22 "2024-01-08T20:25:01Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 8, 2024, 8:30pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/23 "2024-01-08T20:30:01Z")

</div>

True, simplicity is king, but it is good to provide options that might be useful later.

---

<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 8, 2024, 8:38pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/24 "2024-01-08T20:38:13Z")

</div>

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.

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

```

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [January 8, 2024, 8:41pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/25 "2024-01-08T20:41:25Z")

</div>

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.

---

<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 8, 2024, 8:49pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/26 "2024-01-08T20:49:44Z")

</div>

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?

```julia
    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_23_page-0001](https://global.discourse-cdn.com/julialang/original/3X/2/d/2dff7e06c7224edbbd899e03dca6a5b2e51edec4.jpeg)

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [January 8, 2024, 8:53pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/27 "2024-01-08T20:53:24Z")

</div>

```julia
    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/tutorial/#Plot-Attributes)  
[https://docs.juliaplots.org/latest/generated/attributes\_axis/](https://docs.juliaplots.org/latest/generated/attributes_axis/)  
[https://docs.juliaplots.org/latest/generated/attributes\_series/](https://docs.juliaplots.org/latest/generated/attributes_series/)

---

<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 8, 2024, 9:56pm UTC](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394/29 "2024-01-08T21:56:02Z")

</div>

Im trying to make the [small curve](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394) at the start of the line but unfortunately its not doing anything btw tq for the link I learn some new cool stuff 🥰

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

```

 ![plot_35_page-0001](https://global.discourse-cdn.com/julialang/original/3X/4/f/4fc0ed0a49ebcbf8cffe1ccf502925333801d8e9.jpeg)

[Previous page](https://discourse.julialang.org/t/how-to-plot-a-mirror-graph-from-the-one-created/108394.md?page=1)
