# Plotting to multiple separate figures

**URL:** <https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681>\
**Category:** Visualization\
**Tags:** question\
**Created:** [February 3, 2024, 7:06pm UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681 "2024-02-03T19:06:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cbarring](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cbarring](https://discourse.julialang.org/u/cbarring)\
**Post date:** [February 3, 2024, 7:06pm UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/1 "2024-02-03T19:06:37Z")

</div>

Hi. I would like to generate 2 separate figures. These are shown below. Figure 1 shows the numerical solution, plus the actual solution. Figure 2 shows the (tiny) error. I can’t put all this on a single plot since the “solution error” is about 10^-8 x smaller than the solution. There is a similar posting (Plotting multiple figures using Plots,jl), But I have “plot” and “plot!” in figure 1.

```julia
using Plots
# figure 1
plot(sol, seriestype=:scatter, title = "Solution to the linear ODE",
    xaxis = "Time (t)", yaxis = "u(t) (in μm)", label = "Numerical soln",mc=:red, ms=5)
plot!(t1, sol_act, label="Actual",lc=:black, lw=2)
# figure 2
plot(t1, err, title = "Solution Error",seriestype=:scatter, label="errors",mc=:green, ms=6)

```

---

<div class="post-metadata">

**Author:** ![Maucejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maucejo/32/39090_2.png) [@Maucejo](https://discourse.julialang.org/u/Maucejo)\
**Post date:** [February 3, 2024, 7:22pm UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/2 "2024-02-03T19:22:25Z")

</div>

You can add `reuse = false` in the argument of the second `plot` function.

---

<div class="post-metadata">

**Author:** ![cbarring](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cbarring](https://discourse.julialang.org/u/cbarring)\
**Post date:** [February 3, 2024, 9:49pm UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/3 "2024-02-03T21:49:14Z")

</div>

> [@Maucejo](#):
>
> reuse = false

Hi Maucejo. Thanks very much. I could not get reuse=false to do anything. However … I did a google search for “reuse=false” and found this:

> <https://stackoverflow.com/questions/68136957/how-do-i-add-plots-to-separate-figures-using-for-loops-in-julia>

I used this as a starting point, copied their code, and went though many modification/testing cycles. And, I eventually came up with this solution:

```julia
using Plots
pt1 = plot(sol,seriestype=:scatter, title = "Fig 1. Solution to the linear ODE", xaxis = "Time (t)", yaxis = "u(t) (in μm)", label = "Numerical soln",mc=:red, ms=5)
plot!(pt1,t1, sol_act,label="Actual",lc=:black, lw=2)
display(pt1)
plot(t1, err, title = "Fig 2. Solution Error",seriestype=:scatter, label="errors",mc=:green, ms=5)

```

I am very new to Julia. I am borrowing heavily from the work of others. I would greatly appreciate any comments.

Thanks very much

---

<div class="post-metadata">

**Author:** ![Maucejo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maucejo/32/39090_2.png) [@Maucejo](https://discourse.julialang.org/u/Maucejo)\
**Post date:** [February 4, 2024, 7:37am UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/4 "2024-02-04T07:37:00Z")

</div>

Glad you find a working solution. I forgot to mention that `reuse = false` doesn’t work with the GR backend at the moment. That is why, this solution doesn’t work, since GR is the default backend.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [February 4, 2024, 5:19pm UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/5 "2024-02-04T17:19:19Z")

</div>

You could save a little typing for your second plot as follows:

```julia
scatter(t1, err, title = "Fig 2. Solution Error", label="errors", mc=:green, ms=5)

```

---

<div class="post-metadata">

**Author:** ![cbarring](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@cbarring](https://discourse.julialang.org/u/cbarring)\
**Post date:** [February 5, 2024, 1:54am UTC](https://discourse.julialang.org/t/plotting-to-multiple-separate-figures/109681/6 "2024-02-05T01:54:34Z")

</div>

Thanks very much. I am just getting into Julia. I have managed to get a numerical solution to a 2nd order nonlinear ODE problem (which bombed in Python).
