Package options

Display options

The display behaviour of Gnuplot.jl depends on the value of the Gnuplot.options.gpviewer flag:

The Gnuplot.options.gpviewer flag is automatically set when the package is first loaded according to the runtime environment, however the user can change its value at any time to fit specific needs. Further informations and examples for both options are available in this Jupyter notebook.

Package options and initialization

Options

The package options are stored in a global structure available in Julia as Gnuplot.option (the type of the structure is Gnuplot.Options). The most important settings are as follows:

julia> Gnuplot.options.term = "wxt size 700,400";
julia> push!(Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5));

Note that this option affect all the sessions, and that all inserted commands are saved in Gnuplot scripts;



julia> Gnuplot.options.verbose = true;

julia> x = 1.:10;

julia> @gp x x.^2 "w l t 'Parabola'"

julia> save(term="pngcairo size 480,360 fontscale 0.8", output="output.png")

Each line reports the package name (GNUPLOT), the session name (default), the command or string being sent to gnuplot process, and the returned response (line starting with ->). Default value is false;

Package initialization

If you use Gnuplot.jl frequently you may find convenient to collect all the package settings (Options) in a single place, to quickly recall them in a Julia session. A possibility is to put the following code in the ~/.julia/config/startup.jl initialization file (further info here):

macro gnuplotrc()
    return :(
        using Gnuplot;

        # Uncomment the following if you don't have the gnuplot
        # executable installed on your platform:
        #Gnuplot.options.dry = true;

        # Set the proper path if the gnuplot executable is not
        # available in your $PATH
        #Gnuplot.options.cmd = "/path/to/gnuplot";

        # Force a specific display behaviour (see documentation).  If
        # not given explicit Gnuplot.jl will choose the best option
        # according to your runtime environment.
        #Gnuplot.options.gpviewer = true

        # Set the default terminal for interacitve use
        Gnuplot.options.term = "wxt size 700,400";

        # Set the terminal options for the exported MIME types:
        #Gnuplot.options.mime[MIME"image/png"] = "";
        #Gnuplot.options.mime[MIME"image/svg+xml"] = "svg enhanced standalone dynamic";
        #Gnuplot.options.mime[MIME"text/html"] = "svg enhanced standalone mouse dynamic";

        # Set the terminal to plot in a terminal emulator:
        # (try with `save(MIME"text/plain")`):
        #Gnuplot.options.mime[MIME"text/plain"] = "sixelgd enhanced"; # requires vt340 emulation

        # Set the default linetypes
        empty!(Gnuplot.options.init);
        push!(Gnuplot.options.init, linetypes(:Set1_5, lw=1.5, ps=1.5));

        # Initialize the gnuplot REPL using the provided `start_key`.
        if Gnuplot.options.gpviewer;
            Gnuplot.repl_init(start_key='>');
        end;
    )
end

At the Julia prompt you may load the package and the associated settings by typing:

julia> @gnuplotrc

and you're ready to go.