# Plotting bug in VS Code plot pane

**URL:** <https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695>\
**Category:** New to Julia\
**Created:** [August 10, 2020, 3:32pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695 "2020-08-10T15:32:18Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [August 10, 2020, 3:32pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/1 "2020-08-10T15:32:18Z")

</div>

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

```julia
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.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/8/785b01e663bd485b853ada0eb84b3a69eb92c148.png)  
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
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
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.

---

<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:** [August 10, 2020, 4:03pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/2 "2020-08-10T16:03:49Z")

</div>

To those who have reached this thread from Google. See solutions at [Unable to display plot using the REPL. GKS errors - #18 by affans](https://discourse.julialang.org/t/unable-to-display-plot-using-the-repl-gks-errors/12826/18)

I fixed my problem with

```julia
ENV["GKSwstype"] = "nul"
using Plots
p = plot(rand(100))

```

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [August 10, 2020, 6:37pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/3 "2020-08-10T18:37:42Z")

</div>

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

---

<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:** [August 13, 2020, 7:12pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/4 "2020-08-13T19:12:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [August 13, 2020, 9:30pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/5 "2020-08-13T21:30:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sajad\_ghassemi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sajad_ghassemi/32/25241_2.png) [@sajad\_ghassemi](https://discourse.julialang.org/u/sajad_ghassemi)\
**Post date:** [May 20, 2021, 10:58pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/6 "2021-05-20T22:58:13Z")

</div>

but that didn’t work for me, I have the same problem

---

<div class="post-metadata">

**Author:** ![sajad\_ghassemi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sajad_ghassemi/32/25241_2.png) [@sajad\_ghassemi](https://discourse.julialang.org/u/sajad_ghassemi)\
**Post date:** [May 20, 2021, 11:00pm UTC](https://discourse.julialang.org/t/plotting-bug-in-vs-code-plot-pane/44695/7 "2021-05-20T23:00:04Z")

</div>

> [@juliohm](#):
>
> ENV[“GKSwstype”] = “100”

what Can I do?
