First, the way to update plots is to use plot! with the main plot passed in as its first argument so rewriting your code would look like this:
p1 = plot(title = "Plot 1")
p2 = plot(title = "Plot 2")
function sx(E)
a(x) = x^2 + E
b(x) = x + E
plot!(p1, a)
plot!(p2, b)
end
The default gr() backend doesn’t support multiple windows that I know of but the pyplot backend does by setting reuse=false in p1 and p2 so the full code would look like this:
using Plots
pyplot() # Switch to the pyplot backend. Needs to be installed first.
p1 = plot(title = "Plot 1", reuse = false)
p2 = plot(title = "Plot 2", reuse = false)
function sx(E)
a(x) = x^2 + E
b(x) = x + E
plot!(p1, a)
plot!(p2, b)
end
E = [12
24]
sx.(E) # More Julia way of doing your for loop
p1
p2