# Plotting within a call function (MWE)

**URL:** <https://discourse.julialang.org/t/plotting-within-a-call-function-mwe/95087>\
**Category:** General Usage\
**Created:** [February 23, 2023, 3:34pm UTC](https://discourse.julialang.org/t/plotting-within-a-call-function-mwe/95087 "2023-02-23T15:34:18Z")\
**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:** [February 23, 2023, 3:34pm UTC](https://discourse.julialang.org/t/plotting-within-a-call-function-mwe/95087/1 "2023-02-23T15:34:18Z")

</div>

I am experimenting with callbacks, in particular, interactive plotting from within a callback. Here is my code, which runs, except that I do not see a plot displayed. I must be doing something wrong! I am working with Visual Studio Code. Project.toml only contains Plots.jl . I am using Julia 1.8.5 . Thanks for any insights!

```julia
import Plots

function fct(alpha, x)
    return tanh(alpha .* x)
end

function cb(alpha, i, step, x)
    if i % step == 0
        y = fct.(alpha, x)
        println(y)
        Plots.plot(x, y, label = "alpha = $alpha")
    end
end

x = 0 : .1 : 10
cbb(alpha, i, step) = cb(alpha, i, step, x)
    
function demo(cb::Function)
    for i in 1:1000
        alpha = i / 800.
        cb(alpha, i, 50)
    end
end

demo(cbb)
cb(.5, 20, 10, x)

```

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [February 23, 2023, 3:41pm UTC](https://discourse.julialang.org/t/plotting-within-a-call-function-mwe/95087/2 "2023-02-23T15:41:35Z")

</div>

> [@erlebach](#):
>
> `Plots.plot(x, y, label = "alpha = $alpha")`

Try `Plots.plot(x, y, label = "alpha = $alpha") |> display`

---

<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:** [February 23, 2023, 3:53pm UTC](https://discourse.julialang.org/t/plotting-within-a-call-function-mwe/95087/3 "2023-02-23T15:53:00Z")

</div>

Perfect! I keep forgetting to apply display! Thanks for the reminder.
