# How to update a Julia plot without the window grabbing the focus?

**URL:** https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558
**Category:** Visualization
**Created:** [March 7, 2019, 8:35am UTC](https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558 "2019-03-07T08:35:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![HenrikM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrikm/32/17975_2.png) [@HenrikM](https://discourse.julialang.org/u/HenrikM)
#### Post date: [March 7, 2019, 8:35am UTC](https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558/1 "2019-03-07T08:35:19Z")

</div>

When updating a figure in Julia, how to do it without the plot window grabbing the focus?

Let’s say I have the following code:

```julia
using Plots

pyplot()

n = 100
x = collect(range(0, pi, length = n))

for i = 1:30
    y = sin.(x) .+ 0.1 * randn(100)

    plot(x, y, show=true)
    sleep(0)
end

```

When run, the window that displays the plot will grab the focus every time the plot is updated, preventing me from doing anything useful.

How can I update the plot without the window being activated? This would be used for example for monitoring a program in the background.

I asked this question earlier on [SO](https://stackoverflow.com/questions/55025287/how-to-update-a-julia-plot).

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [March 7, 2019, 8:44am UTC](https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558/2 "2019-03-07T08:44:04Z")

</div>

When I use `gr`, I don’t get the focus-grab.

---

<div class="post-metadata">

### Author: ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)
#### Post date: [March 7, 2019, 8:45am UTC](https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558/3 "2019-03-07T08:45:54Z")

</div>

Yes that shouldn’t happen when you don’t `display` the plot.

---

<div class="post-metadata">

### Author: ![HenrikM](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrikm/32/17975_2.png) [@HenrikM](https://discourse.julialang.org/u/HenrikM)
#### Post date: [March 7, 2019, 8:53am UTC](https://discourse.julialang.org/t/how-to-update-a-julia-plot-without-the-window-grabbing-the-focus/21558/4 "2019-03-07T08:53:10Z")

</div>

Yes, this is true! I had just switched to pyplot because it has more features.
