using Pkg
Pkg.activate(".")
function peaks(x, y)
z = 3 * (1 - x)^2 * exp(-x^2 - (y + 1)^2)
z += -10 * (x / 5 - x^3 - y^5) * exp(-x^2 - y^2)
z += -1/3 * exp(-(x+1)^2 - y^2)
return z
end
x = range(-3, stop = 3, length = 100)
y = range(-2, stop = 2, length = 80)
levels = collect(-1:0.2:1)
using Plots
pyplot() # Set the backend to PyPlot
plt = plot(x, y, peaks, levels = levels)
display(plt)
savefig(plt, "test.eps")
savefig(plt, "test.png")
savefig(plt, "test.svg")
savefig(plt, "test.html")
And I get the error message:
ERROR: LoadError: MethodError: no method matching iterate(::Surface{Array{Float64,2}})
Closest candidates are:
iterate(::Any) at essentials.jl:853
iterate(::Any, ::Any) at essentials.jl:847
iterate(::Core.SimpleVector) at essentials.jl:583
...
Stacktrace:
[1] start(::Surface{Array{Float64,2}}) at ./essentials.jl:878
[2] iterate(::Surface{Array{Float64,2}}) at ./essentials.jl:853
[3] copyto!(::Array{Float64,1}, ::Surface{Array{Float64,2}}) at ./abstractarray.jl:654
[4] _collect(::UnitRange{Int64}, ::Surface{Array{Float64,2}}, ::Base.HasEltype, ::Base.HasLength) at ./array.jl:563
[5] collect(::Surface{Array{Float64,2}}) at ./array.jl:557
[6] has_attribute_segments(::Plots.Series) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/utils.jl:691
[7] iter_segments(::Plots.Series) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/utils.jl:197
[8] py_add_series(::Plots.Plot{Plots.PyPlotBackend}, ::Plots.Series) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/backends/pyplot.jl:469
[9] _before_layout_calcs(::Plots.Plot{Plots.PyPlotBackend}) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/backends/pyplot.jl:945
[10] prepare_output(::Plots.Plot{Plots.PyPlotBackend}) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/plot.jl:254
[11] display at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/output.jl:144 [inlined]
[12] gui at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/output.jl:134 [inlined]
[13] display(::REPL.REPLDisplay{REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Plots.Plot{Plots.PyPlotBackend}) at /Users/benoitpasquier/.julia/packages/Plots/ex9On/src/output.jl:150
[14] display(::REPL.REPLDisplay, ::Any) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/REPL/src/REPL.jl:135
[15] display(::Plots.Plot{Plots.PyPlotBackend}) at ./multimedia.jl:287
[16] top-level scope at none:0
[17] include at ./boot.jl:317 [inlined]
[18] include_relative(::Module, ::String) at ./loading.jl:1038
[19] include(::Module, ::String) at ./sysimg.jl:29
[20] include(::String) at ./client.jl:398
[21] top-level scope at none:0
in expression starting at /Users/benoitpasquier/Projects/JuliaPlotting/plot_a_contour_of_peaks.jl:18
where plot_a_contour_of_peaks.jl:18 is the display(plt) line in the MWE above. Am I doing something wrong?
Here is a MWE:
And I get the error message:
where
plot_a_contour_of_peaks.jl:18
is thedisplay(plt)
line in the MWE above. Am I doing something wrong?