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

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:

using Plots


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)

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.

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

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

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