Plotting bug in VS Code plot pane

I am running on a server without sudo access. When I plot in VS Code (using ctrl-enter), I get the following error:

julia>     p = plot(rand(100))
/home/affans/.julia/packages/GR/Atztx/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

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

but it dosn’t prevent the plot. The actual plot shows up in the plot window! It just takes a second or two.


but as you can see, the y axis labels are cut off and the scaling looks weird. And this happens everytime I run the command with ctrl-enter.

Now I found that if I run the code with alt-enter or shift enter (by highlighting the command), the error goes away, plotting is lightning fast, and there is not cutoff of the axis labels.

julia>     p = plot(rand(100))

julia> 

what makes alt-enter different than ctrl-enter? This is somewhat difficult to explain and I can’t figure out what exactly triggers it. Willing to do a screen share to debug this.

EDIT: So somethings it works… sometimes it dosn’t.

julia> p = plot(rand(100))
julia>     p = plot(rand(100))

julia>     p = plot(rand(100))
/home/affans/.julia/packages/GR/Atztx/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

That was me repeatedly running the code in the vscode REPL.

To those who have reached this thread from Google. See solutions at Unable to display plot using the REPL. GKS errors

I fixed my problem with

ENV["GKSwstype"] = "nul"
using Plots
p = plot(rand(100))
1 Like

It would be nice if GR could somehow make these choices automatically so that things would work out-of-the-box…

2 Likes

The problem with this solution is that it kills Terminal/x11 plotting for me. So as long as that environment variable is set, I am confined to plotting in VS Code.

I agree, having to set environment variables in GR in test suites and other terminals manually is kind of sub-optimal, but I don’t have expertise on this to comment or submit a PR.

@affans try to add ENV["GKSwstype"] = "100" to your script. It may avoid the warning.