# Vscode, plots.jl and plotly()

**URL:** <https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436>\
**Category:** VS Code\
**Tags:** plotting\
**Created:** [January 6, 2024, 1:20pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436 "2024-01-06T13:20:28Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 6, 2024, 1:20pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/1 "2024-01-06T13:20:28Z")

</div>

Running latest vscode julia extension 1.65.2 with julia 1.10, the following code will run in the (vscode) julia terminal, with the plot appearing in the web browser, but, if run in the vscode editor, it does not plot in the vscode plot pane. Instead, I get a message in the plot pane that “WebGL is not supported by your browser”

```julia
f(x,y) = -(3*(1-x)^2 * exp(-(x^2) - (y+1)^2)
    - 6*(x/5 - x^3 - y^5) * exp(-x^2 - y^2)
    - 1/3 * exp(-(x+1)^2 - y^2))
 
##
# let's explore it:
using Plots
plotly() # this backend makes nice 3d plots
x = range(-4, step=0.1, stop=4)
y = x
surface(x, y, (x,y)->f(x,y),c=:viridis)
xlabel!("x")
ylabel!("y")

```

---

<div class="post-metadata">

**Author:** ![Naceur\_Bouziani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naceur_bouziani/32/35768_2.png) [@Naceur\_Bouziani](https://discourse.julialang.org/u/Naceur_Bouziani)\
**Post date:** [January 14, 2024, 12:25pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/2 "2024-01-14T12:25:36Z")

</div>

Hello mcreel

Yes, I have the same problem.  
What I can say is that it used to work, but I don’t know why it doesn’t work anymore.  
for me, it’s PlotlyJS that shows this exact behavior, but it worked before

If anyone can help me, that would be great, otherwise we should learn to trace using Mackie.

Naceur

---

<div class="post-metadata">

**Author:** ![benz0li](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benz0li/32/37040_2.png) [@benz0li](https://discourse.julialang.org/u/benz0li)\
**Post date:** [January 14, 2024, 12:51pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/3 "2024-01-14T12:51:27Z")

</div>

> [@mcreel](#):
>
> “WebGL is not supported by your browser”

This is browser related.

@mcreel Do you use Safari on macOS? If so: which versions?

To check if your browser supports WebGL: [https://get.webgl.org](https://get.webgl.org)

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 14, 2024, 1:46pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/4 "2024-01-14T13:46:47Z")

</div>

This code runs fine from the REPL, and the plot appears in Google Chrome. So, there is no browser problem.

However, if the code is run from VScode’s edit pane, the plot does not appear in the plot pane, and the error message that I mentioned appears instead. In the past, the plot did appear in the plot pane.

---

<div class="post-metadata">

**Author:** ![benz0li](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benz0li/32/37040_2.png) [@benz0li](https://discourse.julialang.org/u/benz0li)\
**Post date:** [January 14, 2024, 2:15pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/5 "2024-01-14T14:15:28Z")

</div>

This works fine on my _[reference deployment](https://demo.jupyter.b-data.ch)_ using the [jupyterlab/julia/pubtools](https://github.com/b-data/jupyterlab-julia-docker-stack) image:

 ![Screenshot 2024-01-14 at 15.13.39](https://global.discourse-cdn.com/julialang/original/3X/8/e/8e96cd00c9943115dda55efd64dc31e6f1624928.png)

* * *

OS: Debian 12 (bookworm), Architecture: x86\_64  
code-server v4.20.0 (aka Code v1.85.1)  
Code Julia extension v1.66.2  
Julia v1.10.0

(IJulia v1.24.2)  
Plots v1.39.0

* * *

You may try yourself at [https://demo.jupyter.b-data.ch](https://demo.jupyter.b-data.ch). Login with GitHub account.

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 14, 2024, 2:35pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/6 "2024-01-14T14:35:29Z")

</div>

Oops, sorry for the noise. It seems that I had removed Plotly as a dep from the project, and forgot to add it back in. So, problem solved.

---

<div class="post-metadata">

**Author:** ![Naceur\_Bouziani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naceur_bouziani/32/35768_2.png) [@Naceur\_Bouziani](https://discourse.julialang.org/u/Naceur_Bouziani)\
**Post date:** [January 14, 2024, 3:31pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/7 "2024-01-14T15:31:37Z")

</div>

I will test this

Thanks !

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 14, 2024, 8:52pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/8 "2024-01-14T20:52:14Z")

</div>

Bizarrely enough, I am seeing the problem again, without having made any changes to my Julia or VScode setups.

---

<div class="post-metadata">

**Author:** ![Naceur\_Bouziani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naceur_bouziani/32/35768_2.png) [@Naceur\_Bouziani](https://discourse.julialang.org/u/Naceur_Bouziani)\
**Post date:** [January 15, 2024, 10:23am UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/9 "2024-01-15T10:23:44Z")

</div>

Yep!

That’s the problem!

I don’t have this problem on my HP laptop, but it happens on my desktop computer, which is some kind of game console I have. That isn’t made by a company, someone put together a GeForce with an AMD processor and sold it.  
I’m really starting not to trust this kind of device for my humble research work anymore 😒 maybe it has something to do with that Nvidia being for games only?

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 15, 2024, 11:12am UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/10 "2024-01-15T11:12:48Z")

</div>

I don’t know if this is a problem with the VScode extension, with Plots.jl, or with the plotly() backend as used by Plots.jl. If Someone knows, I can file a proper bug report in the correct place.

To summarize, the code at the end of this message works correctly from the Julia REPL, but it does not produce a plot in the VScode plot pane. Instead, in the plot pane, the message “WebGL is not supported by your browser” is shown. In the past, the code produced a surface plot in the plot pane.

Versions are  
julia\> versioninfo()  
Julia Version 1.10.0  
Commit 3120989f39b (2023-12-25 18:01 UTC)  
Build Info:  
Official [https://julialang.org/](https://julialang.org/) release  
Platform Info:  
OS: Linux (x86\_64-linux-gnu)  
CPU: 8 × Intel(R) Core™ i5-10210U CPU @ 1.60GHz  
WORD\_SIZE: 64  
LIBM: libopenlibm  
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)  
Threads: 1 on 8 virtual cores

The packages in the Project.toml are:  
(plotly) pkg\> st  
Status `~/Desktop/plotly/Project.toml`  
[58dd65bb] Plotly v0.4.1  
[91a5bcdd] Plots v1.39.

VScode julia extension 1.66.2

```julia
using Pkg
Pkg.activate(@ __DIR__ )

f(x,y) = -(3*(1-x)^2 * exp(-(x^2) - (y+1)^2)
    - 6*(x/5 - x^3 - y^5) * exp(-x^2 - y^2)
    - 1/3 * exp(-(x+1)^2 - y^2))
 
##
# let's explore it:
using Plots
plotly() # this backend makes nice 3d plots
x = range(-4, step=0.1, stop=4)
y = x
surface(x, y, (x,y)->f(x,y),c=:viridis)
xlabel!("x")
ylabel!("y")

```

---

<div class="post-metadata">

**Author:** ![Naceur\_Bouziani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/naceur_bouziani/32/35768_2.png) [@Naceur\_Bouziani](https://discourse.julialang.org/u/Naceur_Bouziani)\
**Post date:** [January 15, 2024, 4:59pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/11 "2024-01-15T16:59:20Z")

</div>

Just fine on Jupyter or JupyterLab as s explained by @benz0li  
When it comes to Vscode :  
the @benz0li small code works fine on a machine like Dell or HP, but not anymore with my anonymous box using GeForce and AMD processor

I do not know why !

Nice day to all

Naceur

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 15, 2024, 6:25pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/12 "2024-01-15T18:25:14Z")

</div>

I’m also using Debian, testing, with the same Julia, VScode and julia extension for Vscode, and same Plots. I don’t know the role of IJulia in this, though, I don’t use it.

---

<div class="post-metadata">

**Author:** ![benz0li](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benz0li/32/37040_2.png) [@benz0li](https://discourse.julialang.org/u/benz0li)\
**Post date:** [January 15, 2024, 6:36pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/13 "2024-01-15T18:36:08Z")

</div>

IJulia is only important for Juypter noteboks, not when using code-server v4.20.0 (aka Code v1.85.1) with the Code Julia extension v1.66.2.

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 15, 2024, 8:09pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/14 "2024-01-15T20:09:13Z")

</div>

So, code-server displays plots in the browser, I take it?

---

<div class="post-metadata">

**Author:** ![benz0li](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benz0li/32/37040_2.png) [@benz0li](https://discourse.julialang.org/u/benz0li)\
**Post date:** [January 15, 2024, 8:24pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/15 "2024-01-15T20:24:23Z")

</div>

Yes. But VS Code is a web application, too.  
ℹ Built with HTML5, JavaScript, and other Web technologies, using Chromium for presentation.

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [January 15, 2024, 8:41pm UTC](https://discourse.julialang.org/t/vscode-plots-jl-and-plotly/108436/16 "2024-01-15T20:41:54Z")

</div>

The problem I’m seeing is when using the installable version of VScode, which uses the plot pane. I would like to solve the problem on that setup, because it is what most of my students use. Actually, they will mostly be using Windows, and I’m not sure if the problem occurs on Windows.
