How to plot outside VS Code?

I noticed that in the plugin Julia there is the option to plot outside VSCode instead of using the plot pane.
Screenshot
This in my mind should create a plot window as when I makes plot directly form the julia console (not inside the REPL of VSCode).
However nothings happens. The REPL stutters a bit when you try to make the first plot, just as it happens when you make the first plots in other situations, but then nothing happens.

Using Linux Here, with Julia 1.5.2

[Why I want this? Apart that I prefer to have a separate window instead that the plot pane, usually the plot pane is a bit slower/tends to not display everything it should (my scripts usually do plots inside a for loop at runtime, updating constantly). As a temporary workaround I am doing all my plots outside the VSCode REPL, that shows plots correctly]

1 Like

I think you need to restart your current Julia process for that setting to take effect.
We’ll definitely look into making that a bit smoother at some point though!

2 Likes

I did indeed! I already thought that could be a thing, but sadly it had no effect.

I have exactly the same problem. I cant get a standalone Plots.jl plot whatever I do. this might be a vscode bug. (?) I have julia 1.5.0, vscode 1.50.1, Plots.jl 1.7.3 and extension version 1.0.8.

One way would be to use something like Gnuplots, and save the plot as a .png. Also why do you want the Plot outside Julia? with Weave.jl you can convert a Julia Markdown to LaTeX for editing and publishing .pdf s or to .html, for creating web pages.

Actually I just would like to plot outside VScode :grinning:

I’m not sure I get what you mean. Do you mean in another type of document? or a different editor, such as using plain text?

I am sorry if I was not very clear. As explained before the original problem is what happens when I plot from the julia REPL inside vscode. If I thick the option “use plot pane” as in the first post it really uses the plot pane. But it is really slow, so I would simply like to plot with a different gtk window, as when I open julia from a vanilla terminal and run plot from there (but with all the features and advantages of the REPL inside vscode)

1 Like

Ok, I probably would like to do that too. It does seem to be a bit slow. I’ve been doing most everything inside VS though.

IIRC the display handling is broken in the latest normal release. Insiders has a fix for that, in case you wanna give it a go.

Any news on this problem?

I have a similar problem using PyPlot. When I run a script in vscode using eg shift return the script runs without error but I do not get any plots. Not external from vs code and not in a plot pane. It used to work before.

If I start a new julia REPL in vscode and paste in the same code it works fine.

If you are using PyPlot, then calling pygui(true) before issuing your plot commands might do the trick (it does for me in VSCode at least; but this wasn’t always necessary - seems to have changed at some point during the last few months?).

2 Likes

You could try ElectronDisplay.jl.

julia> using Plots, ElectronDisplay

julia> scatter(1:4) |> electrondisplay()
1 Like

If Plots.jl is not a requirement you may use Gnuplot.jl as follows:

using Gnuplot
Gnuplot.options.gpviewer = true # to avoid using plot pane
@gp rand(100)

It will open a separate window (running in a separate process) showing the plot, with no temporary file involved, mouse tracking / zooming, and possibility to export the plot in several formats.

Another option is to use Gaston.jl, which also relies on gnuplot, and may become a Plots.jl backend in the near future.

No problem for me in Win10, Julia 1.5.3 and using Plots. After unchecking in VS Code options the “Display plots within vscode” and restarting Julia, the first plot opened in a new window labelled “GKS QtTerm”

1 Like

Thanks! Running pygui(true) solved my problem.
Now plots show up in an external window again. I have no idea why I didn’t need the pygui(true) before and on another machine the same code runs just fine without it.

2 Likes

This is a great option thanks! I found it didn’t work with the (), it worked like this:

scatter(1:4) |> electrondisplay

or

electrondisplay(scatter(1:4))
1 Like

In my experience once the packages Plots and ElectronDisplay are loaded with using it is enough to do

scatter(1:4)
1 Like