2

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?

1 Answer 1

3

Try reuse=false as in this example below:

using Plots
pyplot()
p1 = plot(rand(5))
p2 = plot(rand(50), reuse=false)
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks - ah I tried that with gr() before but it didn't work. Seems like I do have to use the pyplot(). But pyplot() is nice anyway so thanks. Can I somehow set reuse=false after generating p2? Because if I have two functions returning two plots I can't get that working.
Most likely it is possible via gr but it is not part of the standard API and I have not been doing that. As far as I know this would be the code to start with github.com/jheinen/GR.jl/blob/master/examples/gtk_ex.jl
Thanks - can't see why it is such a big hassle to show several plots in several windows. :( I'll recheck but I thought gr doesn't support the reuse property.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.