Plotting while working with VS Code remote - ssh

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

ssh -Y user@host

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

    "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

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.

3 Likes

Thanks! This is useful for my workflow.

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

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

Have you seen this?

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).

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.

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

Hi,

if you have no access to X11 this vscode extension is very useful.

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

Plots + pyplot() also works fine in VSCode.

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’.

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 --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 project=.

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

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?