# How to save multiple plot through a loop?

**URL:** <https://discourse.julialang.org/t/how-to-save-multiple-plot-through-a-loop/54575>\
**Category:** New to Julia\
**Tags:** plotting, pyplot\
**Created:** [February 4, 2021, 12:27am UTC](https://discourse.julialang.org/t/how-to-save-multiple-plot-through-a-loop/54575 "2021-02-04T00:27:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![minou92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/minou92/32/21676_2.png) [@minou92](https://discourse.julialang.org/u/minou92)\
**Post date:** [February 4, 2021, 12:27am UTC](https://discourse.julialang.org/t/how-to-save-multiple-plot-through-a-loop/54575/1 "2021-02-04T00:27:14Z")

</div>

I have been trying to save multiple plots with different names through a loop.  
I am looking for the Julia equivalent of python script: plt.savefig('ID+str(i).‘png’).  
I tested this savefig(“C:/Julia\_data/ID”+str(i) “.pdf”) but obviously it does work.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [February 4, 2021, 1:26am UTC](https://discourse.julialang.org/t/how-to-save-multiple-plot-through-a-loop/54575/2 "2021-02-04T01:26:10Z")

</div>

In Julia you concatenate strings with `*`, not `+`.

It would be helpful for you to post the error message so we can confirm this is your problem.

---

<div class="post-metadata">

**Author:** ![Daneel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daneel/32/175_2.png) [@Daneel](https://discourse.julialang.org/u/Daneel)\
**Post date:** [February 4, 2021, 8:46am UTC](https://discourse.julialang.org/t/how-to-save-multiple-plot-through-a-loop/54575/3 "2021-02-04T08:46:46Z")

</div>

I would also recommend using `joinpath` to create a path. It’s more robust if you want your code to run on multiple operating systems and I find it to be a good habit.

```julia
path = raw“C:\Julia_data”
savefig(joinpath(path,"ID" * str(i) * “.pdf”))

```
