Using PyPlot in JuliaPro


#1

Hi

I am using JuliaPro on Windows 7, which runs Julia 0.5.1.
If I paste

using Plots
pyplot() # Switch to using the PyPlot.jl backend
plot(rand(5,5),linewidth=2,title="My Plot B")

in the REPL, I get a new pane with a plot. If however I have the same code in a file and press “Run File”, the file is executed, but no plot appears. What did I miss?


#2

I’m not familiar with Plots but PyPlot has an interactive plotting setting which might be the cause of this. Does this work?

using Plots
ion() # Interactive Plotting ON
pyplot()
plot(rand(5,5),linewidth=2,title="My Plot B")

The opposite function is ioff().


#3

That didn’t work, unfortunately.

But I found an acceptable solution for now: if my script ends with
savefig("pyplot_test.png")
then JuliaPro opens a pane named "pyplot_test.png" which displays the plot.

Cheers!


#4

Evaluate File basically does the same as include(file) at the REPL, which doesn’t show plots (or output in general) either, except for the last line.
Explicitly calling display(plot(...)) or similar should work however (I didn’t test that with PyPlot though).