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:
dry::Bool: if true all new sessions will be started as Dry sessions. Default isfalse, but if the package is not able to start a gnuplot process it will automatically switch totrue;init::Vector{String}: initialization commands to be executed when a new session is created. Default is an empty vector. It can be used to, e.g., set a custom terminal:
julia> push!(Gnuplot.options.init, "set term sixelgd");Note that this is option affect all the newly created sessions, not the older ones. Also note that the commands in Gnuplot.options.init are not saved in Gnuplot scripts;
reset::Vector{String}: initialization commands to be executed when a session is reset. Default is an empty vector. It can be used to, e.g., set custom linetypes or palette:
julia> push!(Gnuplot.options.reset, linetypes(:Set1_5, lw=1.5, ps=1.5));Note that this is option affect all the sessions. Also note that the commands in Gnuplot.options.reset are saved in Gnuplot scripts;
verbose::Bool: a flag to set verbosity of the package. In particular if it istrueall communication with the underlying process will be printed on stdout. E.g.:
julia> Gnuplot.options.verbose = true;
julia> x = 1.:10;
julia> @gp x x.^2 "w l t 'Parabola'"
GNUPLOT (default) unset multiplot
GNUPLOT (default) set output
GNUPLOT (default) reset session
GNUPLOT (default) $data1 << EOD
GNUPLOT (default) 1.0 1.0
GNUPLOT (default) 2.0 4.0
GNUPLOT (default) 3.0 9.0
GNUPLOT (default) 4.0 16.0
GNUPLOT (default) ...
GNUPLOT (default) EOD
GNUPLOT (default)
GNUPLOT (default) reset
GNUPLOT (default) plot \
$data1 w l t 'Parabola'
julia> save(term="pngcairo size 480,360 fontscale 0.8", output="output.png")
GNUPLOT (default) reset
GNUPLOT (default) print GPVAL_TERM
GNUPLOT (default) -> wxt
GNUPLOT (default) print GPVAL_TERMOPTIONS
GNUPLOT (default) -> 0 enhanced
GNUPLOT (default) set term pngcairo size 480,360 fontscale 0.8
GNUPLOT (default) set output 'output.png'
GNUPLOT (default) plot \
$data1 w l t 'Parabola'
GNUPLOT (default) set output
GNUPLOT (default) set term wxt 0 enhancedEach 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;
cmd::String: command to start the gnuplot process, default value is"gnuplot". If you need to specify a custom path to the gnuplot executable you may change this value;default::Symbol: default session name, i.e. the session that will be used when no session name is provided;preferred_format::Symbol: preferred format to send data to gnuplot. Value must be one of:bin: provides best performances for large datasets, but uses temporary files;text: may be slow for large datasets, but no temporary file is involved;auto(default) automatically choose the best strategy.
Package initialization
If you use Gnuplot.jl frequently you may find convenient to collect all the package settings (see Options) in a single place, to quickly recall them in a Julia session. I suggest to put the following code in the .julia/config/startup.jl initialization file (further info here):
macro gnuplotrc()
return :(
using Gnuplot;
# Uncomment following to true if you don't have the gnuplot
# executable installed on your platform:
#Gnuplot.options.dry = true;
# Uncomment the following and set the proper path if the
# gnuplot executable is not in your $PATH
#Gnuplot.options.cmd = "/path/to/gnuplot";
# Set the default terminal for interacitve use
empty!(Gnuplot.options.init);
push!(Gnuplot.options.init, "set term wxt size 700,400");
# Set the default linetypes
empty!(Gnuplot.options.reset);
push!(Gnuplot.options.reset, linetypes(:Set1_5, lw=1.5, ps=1.5));
# Initialize the gnuplot REPL using the provided `start_key`.
# Comment the following to disable the REPL.
Gnuplot.repl_init(start_key='>');
)
endAt the Julia prompt you may load the package and the associated settings by typing:
julia> @gnuplotrcand you're ready to go.