# 3d graph error

**URL:** <https://discourse.julialang.org/t/3d-graph-error/54224>\
**Category:** Visualization\
**Created:** [January 29, 2021, 8:27pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224 "2021-01-29T20:27:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Evan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan/32/25369_2.png) [@Evan](https://discourse.julialang.org/u/Evan)\
**Post date:** [January 29, 2021, 8:27pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224/1 "2021-01-29T20:27:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aquarelleX332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarellex332/32/21048_2.png) [@aquarelleX332](https://discourse.julialang.org/u/aquarelleX332)\
**Post date:** [January 29, 2021, 9:09pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224/2 "2021-01-29T21:09:30Z")

</div>

What is the result of this command?

```julia
julia> backend()

```

I tried your code successfully with:

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

```

However I am currently using Plots.GRBackend()

---

<div class="post-metadata">

**Author:** ![Evan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan/32/25369_2.png) [@Evan](https://discourse.julialang.org/u/Evan)\
**Post date:** [January 29, 2021, 9:44pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224/4 "2021-01-29T21:44:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aquarelle332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarelle332/32/20816_2.png) [@aquarelle332](https://discourse.julialang.org/u/aquarelle332)\
**Post date:** [January 29, 2021, 9:59pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224/5 "2021-01-29T21:59:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Evan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan/32/25369_2.png) [@Evan](https://discourse.julialang.org/u/Evan)\
**Post date:** [January 29, 2021, 10:51pm UTC](https://discourse.julialang.org/t/3d-graph-error/54224/6 "2021-01-29T22:51:55Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![aquarelleX332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarellex332/32/21048_2.png) [@aquarelleX332](https://discourse.julialang.org/u/aquarelleX332)\
**Post date:** [January 30, 2021, 5:51am UTC](https://discourse.julialang.org/t/3d-graph-error/54224/7 "2021-01-30T05:51:24Z")

</div>

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](https://github.com/JuliaPlots/Plots.jl/issues/3259).

---

<div class="post-metadata">

**Author:** ![Evan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evan/32/25369_2.png) [@Evan](https://discourse.julialang.org/u/Evan)\
**Post date:** [February 1, 2021, 3:16am UTC](https://discourse.julialang.org/t/3d-graph-error/54224/8 "2021-02-01T03:16:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aquarelle332](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquarelle332/32/20816_2.png) [@aquarelle332](https://discourse.julialang.org/u/aquarelle332)\
**Post date:** [February 1, 2021, 8:38am UTC](https://discourse.julialang.org/t/3d-graph-error/54224/9 "2021-02-01T08:38:31Z")

</div>

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