# Plots: replace curve

**URL:** <https://discourse.julialang.org/t/plots-replace-curve/106448>\
**Category:** General Usage\
**Created:** [November 20, 2023, 5:22am UTC](https://discourse.julialang.org/t/plots-replace-curve/106448 "2023-11-20T05:22:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [November 20, 2023, 5:22am UTC](https://discourse.julialang.org/t/plots-replace-curve/106448/1 "2023-11-20T05:22:44Z")

</div>

How does one replace a curve with another one in a plot?  
I have this loop

```julia
p = ptrans[1]
    pl = plot(vec(distances), vec(p), leg = false, ylims = (-1000, 1000))
    for i in eachindex(d["times"])
        p = ptrans[i]
        pl = plot!(pl, vec(distances), vec(p))
        sleep(1)
        display(pl)
    end

```

But it simply adds additional curves to the plot instead of replacing the one that is there. I want a single curve which changes as I go through the loop.  
I use Plots with gr().

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [November 20, 2023, 5:42am UTC](https://discourse.julialang.org/t/plots-replace-curve/106448/2 "2023-11-20T05:42:29Z")

</div>

call `plot` instead of `plot!`?
