# Plotting while working with VS Code remote - ssh

**URL:** <https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309>\
**Category:** VS Code\
**Created:** [February 7, 2020, 4:33pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309 "2020-02-07T16:33:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastianpech](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastianpech/32/6715_2.png) [@sebastianpech](https://discourse.julialang.org/u/sebastianpech)\
**Post date:** [February 7, 2020, 4:33pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/1 "2020-02-07T16:33:36Z")

</div>

Hi,

I found a nice and simple solution for plotting while working with vscode remote over ssh. Maybe it’s obvious or there is a simpler solution, but wanted to share it anyways: I connect an extra ssh session with X11 forwarding

```julia
ssh -Y user@host

```

and set the display env variable for the vscode remote workspace to

```julia
    "terminal.integrated.env.linux": {
        "DISPLAY": "localhost:10.0",
    }

```

`localhost:10.0` seems to be consistent if you only open one window. You can check with

```julia
echo $DISPLAY

```

in the extra session that’s connected with X11 forwarding.

And that’s it. Afterwards you can plot on the remote and it uses your local xserver for displaying the window. Tested it with gr.

---

<div class="post-metadata">

**Author:** ![Balinus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/balinus/32/243_2.png) [@Balinus](https://discourse.julialang.org/u/Balinus)\
**Post date:** [February 7, 2020, 4:40pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/2 "2020-02-07T16:40:22Z")

</div>

Thanks! This is useful for my workflow.

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [May 7, 2020, 6:55pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/3 "2020-05-07T18:55:54Z")

</div>

I have the following error, but not sure if its display related, plots, or x11 issue

```julia
julia> x = 1:10; y = rand(10); # These are the plotting data

julia> plot(x, y)
/home/affans/.julia/packages/GR/NSt7D/src/../deps/gr/bin/gksqt: error while loading shared libraries: libQt5Widgets.so.5: cannot open shared object file: No such file or directory
connect: Connection refused
GKS: can't connect to GKS socket application
Did you start 'gksqt'?

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine FILLAREA
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine TEXT
GKS: GKS not in proper state. GKS must be either in the state WSAC or SGOP in routine POLYLINE

```

---

<div class="post-metadata">

**Author:** ![zekeriya.sari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zekeriya.sari/32/13695_2.png) [@zekeriya.sari](https://discourse.julialang.org/u/zekeriya.sari)\
**Post date:** [May 7, 2020, 7:15pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/4 "2020-05-07T19:15:12Z")

</div>

Have you seen this?

> [@Unable to display plot using the REPL. GKS errors](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/2):
>
> It seems that the Qt5 run-time is missing on your laptop. sudo apt-get install qt5-default should fix the problem.

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [May 7, 2020, 7:17pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/5 "2020-05-07T19:17:09Z")

</div>

Yes, i just came across that. Unfortunately I am running on a cluster without admin access. I thought maybe `Plots.jl` would supply its own libraries. I can’t even use `Gnuplot.jl` because of incompatible version (but this is something maybe I can ask the sysadmin to update).

---

<div class="post-metadata">

**Author:** ![zekeriya.sari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zekeriya.sari/32/13695_2.png) [@zekeriya.sari](https://discourse.julialang.org/u/zekeriya.sari)\
**Post date:** [May 7, 2020, 7:21pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/6 "2020-05-07T19:21:31Z")

</div>

Here is the case. I had the same type of errors that you posted. Even though I installed qt5-default, I had to add `ENV["GKSwstype"] = "100"` in my `startup.jl` file, and the problem disappeared. May be you can try the second step.

> [@Gks Error When Plotting in VS Code](https://discourse.julialang.org/t/gks-error-when-plotting-in-vs-code/36618/11):
>
> Setting ENV["GKSwstype"] = "100" (in startup.jl to avoid setting all the time Julia is launched) solved the problem. Now nothing wrong with using GR as a backed of Plots in VSCode.

Edit: Of course the library `libQt5Widgets.so` must be on the system.

---

<div class="post-metadata">

**Author:** ![Oto\_Brzobohaty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oto_brzobohaty/32/10370_2.png) [@Oto\_Brzobohaty](https://discourse.julialang.org/u/Oto_Brzobohaty)\
**Post date:** [May 7, 2020, 7:32pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/7 "2020-05-07T19:32:57Z")

</div>

Hi,

if you have no access to X11 this [vscode extension](https://code.visualstudio.com/docs/remote/ssh) is very useful.

I use Plots + plotlyjs() and I have an interactive plot in Plot panel.

---

<div class="post-metadata">

**Author:** ![zekeriya.sari](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zekeriya.sari/32/13695_2.png) [@zekeriya.sari](https://discourse.julialang.org/u/zekeriya.sari)\
**Post date:** [May 7, 2020, 7:39pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/8 "2020-05-07T19:39:00Z")

</div>

Plots + pyplot() also works fine in VSCode.

---

<div class="post-metadata">

**Author:** ![joehays](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joehays/32/20996_2.png) [@joehays](https://discourse.julialang.org/u/joehays)\
**Post date:** [January 14, 2021, 9:16pm UTC](https://discourse.julialang.org/t/plotting-while-working-with-vs-code-remote-ssh/34309/9 "2021-01-14T21:16:50Z")

</div>

Using PowerShell, I ssh’d to my Ubuntu20.04 workstation from my Windows laptop with X11forwarding support on. xeyes runs and displays just fine. However, running the following in the REPL initially produced the same error as ‘affans’.

```julia
using Plots
x = 1:10; y = rand(10); # These are the plotting data
plot(x, y

```

The suggestion from ‘zekeriya.sari’ took the error away but did not make the plotting work. Running the above code compiles and runs just fine but no plot is displayed.

Putting the code snippet in tests/myTest.jl and running,

```julia
julia --project=. tests/myTest.jl

```

also compliles and runs without error but no plot is displayed.

Interestingly, if I run VS Code on my laptop, with Remote Development, Remote - SSH, and Julia extensions enabled, I do successfully get a plot but only if I use the Julia Extension REPL (meaning, I launch the REPL using alt-j, alt-o). The plot is displayed as another tab in the VS Code workspace environment.

Further testing showed that if I run the REPL manually from the integrated terminal (e.g. running,

```julia
julia project=.

```

the above code snippet compiles and runs without problem but does NOT display the plot. Likewise, runing

```julia
julia --project=. tests/myTest.jl

```

from the VS Code integrated terminal successfully compiles and runs but no plot is displayed.

So, only 1 of these 4 scenarios successfully plotted, using the Julia VS Code extension REPL.

This is find but I am curious how to make this work without the REPL as I am doing most development right now without the REPL (embedding Julia code in an existing C++ program).

Thoughts?
