3d graph error

I’m getting an error from simple 3d plots, example of plot and error is below. What am i doing wrong?

using Plots; pyplot()
x=range(-2,stop=2,length=100)
y=range(sqrt(2),stop=2,length=100)
f(x,y) = x*y-x-y+1
plot(x,y,f,st=:surface,camera=(-30,30))

julia> p = plot(x,y,f,st=:surface)
Error showing value of type Plots.Plot{Plots.PyPlotBackend}:
ERROR: KeyError: key :cbar_width not found
Stacktrace:
[1] getindex at ./dict.jl:467 [inlined]
[2] getindex at /Users/modelt/.julia/packages/RecipesPipeline/uPBKQ/src/utils.jl:18 [inlined]
[3] _update_plot_object(::Plots.Plot{Plots.PyPlotBackend}) at /Users/modelt/.julia/packages/Plots/oZheM/src/backends/pyplot.jl:1410
[4] prepare_output(::Plots.Plot{Plots.PyPlotBackend}) at /Users/modelt/.julia/packages/Plots/oZheM/src/plot.jl:201
[5] show at /Users/modelt/.julia/packages/Plots/oZheM/src/output.jl:214 [inlined]
[6] __binrepr at ./multimedia.jl:159 [inlined]
[7] _textrepr at ./multimedia.jl:151 [inlined]
[8] #stringmime#6 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Base64/src/Base64.jl:43 [inlined]
[9] stringmime at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Base64/src/Base64.jl:43 [inlined]
[10] display(::VSCodeServer.InlineDisplay, ::MIME{Symbol(“image/svg+xml”)}, ::Plots.Plot{Plots.PyPlotBackend}) at /Users/modelt/.vscode/extensions/julialang.language-julia-1.0.10/scripts/packages/VSCodeServer/src/display.jl:25
[11] display(::VSCodeServer.InlineDisplay, ::String, ::Any) at ./multimedia.jl:216
[12] display(::VSCodeServer.InlineDisplay, ::Plots.Plot{Plots.PyPlotBackend}) at /Users/modelt/.vscode/extensions/julialang.language-julia-1.0.10/scripts/packages/VSCodeServer/src/display.jl:87
[13] display(::Any) at ./multimedia.jl:328
[14] #invokelatest#1 at ./essentials.jl:710 [inlined]
[15] invokelatest at ./essentials.jl:709 [inlined]
[16] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:238
[17] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:223
[18] (::REPL.var"#do_respond#54"{Bool,Bool,VSCodeServer.var"#40#41"{REPL.LineEditREPL,REPL.LineEdit.Prompt},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:822
[19] (::REPL.var"#69#78")(::Any, ::Any, ::Vararg{Any,N} where N) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:1086
[20] #invokelatest#1 at ./essentials.jl:710 [inlined]
[21] invokelatest at ./essentials.jl:709 [inlined]
[22] (::REPL.LineEdit.var"#22#23"{REPL.var"#69#78",String})(::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:1364
[23] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2447
[24] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2350
[25] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:1144
[26] (::REPL.var"#38#42"{REPL.LineEditREPL,REPL.REPLBackendRef})() at ./task.jl:356

What is the result of this command?

julia> backend()

I tried your code successfully with:

using Plots
[...]
p = plot(x,y,f,st=:surface)

However I am currently using Plots.GRBackend()

julia> backend()
Plots.PyPlotBackend()

Could I just switch to Plots.GRBackend()?

I produced a similar plot successfully just a few days ago but have been doing a-lot of work since then.

It doesn’t cost anything to try with GR.
Afterwards it will be time to understand why pyplot presents an error.

1 Like

The following worked. I would like to use pyplot() again.

using Plots
Plots.GRBackend()
x = 0.5:0.01:1.50
y = 0.5:0.01:1.50
f(x,y) = abs2(x-y)
p = plot(x,y,f,st=:surface)

I repeated your former code after shifting from GR to pyplot (freshly installed on julia-1.5.3;
Kubuntu (x86_64)) without error.

However, a bug report --describing the same problem you mentionned-- was recently posted here.

Thank you for responding with the link.

Interestingly I was able to put my code into an R-markdown file and run it fine. I think it’s a problem using Visual studios given this most recent fact.

Appreciate your help

This is possible.
I tested the code in Atom/Juno.
Glad to know that you succeeded.