Gnuplot from VSCode: no plot

When I run gnuplot from within vscode, I get nothing: no error, but no plot either. Running gnuplot from the shell works fine.

This works:

shell> gnuplot

        G N U P L O T
        Version 5.2 patchlevel 8    last modified 2019-12-01

        Copyright (C) 1986-1993, 1998, 2004, 2007-2019
        Thomas Williams, Colin Kelley and many others

        gnuplot home:     http://www.gnuplot.info
        faq, bugs, etc:   type "help FAQ"
        immediate help:   type "help"  (plot window: hit 'h')

Terminal type is now 'windows'
Options are '0 color solid butt enhanced standalone size 887,435'
Encoding set to 'cp1252'.
gnuplot> plot sin(x)
gnuplot> quit

This doesn’t:

julia> using Gnuplot

julia> @gp "plot sin(x)"

Does anyone have any clue what’s going on?

Julia 1.6.2, Windows 10.

Try setting of Gnuplot.options.gpviewer = true to use the gnuplot terminal window (further info in the docs and in the repo issue).

2 Likes

This solution stopped working. No plots again, and this time I am sure to have this setting in.

Update. I got the plot to show, but I had to use this incantation in the command line. It was not enough to have it in the module doing the plotting.

The gpviewer is first set during module initialization, i.e. in the Gnuplot.__init__ function.
Hence the approach should be as follows:

using Gnuplot
Gnuplot.options.gpviewer = true

There is no other possibility for this setting to be changed within the Gnuplot.jl package, so once set it is supposed to retain its value for the whole session (unless explicitly changed).