# Plot inside a function

**URL:** <https://discourse.julialang.org/t/plot-inside-a-function/35582>\
**Category:** General Usage\
**Created:** [March 5, 2020, 3:05pm UTC](https://discourse.julialang.org/t/plot-inside-a-function/35582 "2020-03-05T15:05:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [March 5, 2020, 3:05pm UTC](https://discourse.julialang.org/t/plot-inside-a-function/35582/1 "2020-03-05T15:05:57Z")

</div>

Consider the function

```julia
using Plots
function test_plot()
    a = Any[]
    t = [1,2,3]
    push!(a, [2,3,4])
    push!(a, [3,4,5])
    plot(t, a[1])
    return a
end

data = test_plot()

```

When it is executed, the plot does not show in the Juno IDE. However, if I type the plot command in the REPL, the plot shows:

```julia
plot(data[1])

```

How does one execute plotting commands from within a function so that the plot shows interactively in the Plots window in the Juno IDE? Thanks.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [March 5, 2020, 3:09pm UTC](https://discourse.julialang.org/t/plot-inside-a-function/35582/2 "2020-03-05T15:09:12Z")

</div>

Call `display()` on the plot object (there are other ways, see: [The plot (with Plots pkg) not displayed, if plot(...) is not the last operator](https://discourse.julialang.org/t/the-plot-with-plots-pkg-not-displayed-if-plot-is-not-the-last-operator/34410))

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [March 5, 2020, 3:49pm UTC](https://discourse.julialang.org/t/plot-inside-a-function/35582/3 "2020-03-05T15:49:46Z")

</div>

Thanks!
