xotix
xotix

Reputation: 530

Show Two Plots in Separate Windows Using Plots

let's assume I have a file called plot.jl:

using Plotsfunction plotSine()
    x = LinRange(0,2π, 101)
    y = sin.(x)    gr()
    p = plot(x,y, title="Sine from 0 to 2π", xlabel="x", ylabel="y")
    display(p)
endfunction plotTwoFunctions()
    x = LinRange(0, 2, 101)
    y1 = exp.(x)
    y2 = log.(x)    gr()
    p = plot(x,y1, title="Two functions", xlabel="x x", ylabel="y")
    plot!(p, x,y2)
    display(p)
endplotSine()
plotTwoFunctions()

I starta REPL session and include it and it opens the window for the sine function plot but that get's instantly overwritten by the second function call.

Is there a blocking display() function? Can I somehow force a new window to open?

Upvotes: 2

Views: 1570

Answers (1)

Przemyslaw Szufel
Przemyslaw Szufel

Reputation: 42244

Try reuse=false as in this example below:

using Plots
pyplot()
p1 = plot(rand(5))
p2 = plot(rand(50), reuse=false)

Upvotes: 3

Related Questions