Surface plot not showing up in script

with

using Plots; pyplot()

after I generate some gridded data, xx, yy, zz, I call

surface(xx,yy,zz)

Now, I find that if I run the script containing this code, the figure does not appear. If I include a savefig, the picture is generated as expected. If I call show() instead, the figure appears, but the data is never plotted.

This works for me:

julia> using Plots; pyplot()

shell> nano myplot.jl  # Do some editing.
# File myplot.jl

xx = yy = linspace(0, 1, 10)
zz = [x^2 + sin(y) for x in xx, y in yy]

surface(xx, yy, zz)
julia> include("myplot.jl")

And then I get the plot.

I agree that works. What does not work for me is calling julia myplot.jl from the command line.

I am not sure how to make that work to be honest. Although, is it 100% necessary that you run the script from the command line?

I’m not sure how one would get it to work from the command line but I’d like to point out that it’s actually not ideal to use Plots from the command line: the first plot is very slow due to precompilation and, if you call it from command line, you pay that cost every time. Using the REPL and running your file with include(...) is a much better user experience. If you need to use the command line, simply toggle it from the REPL typing ;

1 Like