# Plot and plot!

**URL:** <https://discourse.julialang.org/t/plot-and-plot/58372>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [April 1, 2021, 3:39pm UTC](https://discourse.julialang.org/t/plot-and-plot/58372 "2021-04-01T15:39:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [April 1, 2021, 3:39pm UTC](https://discourse.julialang.org/t/plot-and-plot/58372/1 "2021-04-01T15:39:59Z")

</div>

Hi,

I wonder how to avoid to duplicate my plot commands (`plot` then `plot!`) when I want to add multiples curves using Plots.  
Here is the MWE that I would like to simplify:

```julia
 using Plots
 function testplots()
        theme(:dark)
        ωs=(1,2,3,4)
        n=100
        xs=[2π*i/n for i ∈ 0:n] 
        p=nothing
        for (i,ω) ∈ enumerate(ωs)
            if i==1 # a bit verbose...
                p=plot(xs,sin.(ω .* xs),label="ω=$ω") 
            else
                plot!(p,xs,sin.(ω .* xs),label="ω=$ω") # duplicate :(
            end
        end
        p
    end 

```

![toto](https://global.discourse-cdn.com/julialang/original/3X/1/d/1dd9c94fec7acf41700c4966d2f8bb47aefe4703.png)

Thank you for your help !

---

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [April 1, 2021, 3:45pm UTC](https://discourse.julialang.org/t/plot-and-plot/58372/2 "2021-04-01T15:45:18Z")

</div>

OK, I think I found a satisfactory solution:

```julia
using Plots
function testplots2()
        theme(:dark)
        ωs=(1,2,3,4)
        n=100
        xs=[2π*i/n for i ∈ 0:n] 
        p=Plots.plot()
        for ω ∈ ωs
            plot!(p,xs,sin.(ω .* xs),label="ω=$ω")
        end
        p
 end 

```
