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

#1

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

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.

0 Likes

#2

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

0 Likes

#3

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

0 Likes

#4

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

0 Likes