API

Index

Documentation

GnuplotScripting.GnuplotScriptType
gp = GnuplotScript(;direct_plot = true)

Create a gnuplot script gp. If direct_plot is true, simultaneously plot the registered operations.

Usage example

You can perform a simple plot as follows:

gp = GnuplotScript(;direct_plot = true)

X=[-pi:0.1:pi;];
Ys = sin.(X);
Yc = cos.(X);

id = register_data(gp,hcat(X,Ys,Yc))
free_form(gp,"replot '$id' u 1:3 w l t 'cos'")
free_form(gp,"replot '$id' u 1:2 w l t 'sin'")

The plot will be created immediately.

Also see

source
GnuplotScripting.free_formMethod
free_form(gp::GnuplotScript,gp_line::AbstractString)

Write gnuplot commands. This command line is directly forwarded to Gnuplot. The only difference is that you can use replot even for the first plot. This is convenient when you chain plots, you do not have to worry if the current command is the first plot.

Usage example

using GnuplotScripting

gp = GnuplotScript()

free_form(gp, "replot sin(x) lw 2 t 'a trigonometric function'")
source
GnuplotScripting.register_dataMethod
register_data(gp::GnuplotScript,
              data::AbstractVecOrMat;
              copy_data::Bool=true) -> id

Register data and return the associated data identifier. Registered data is embedded in the plot script file. The returned id is used to reference registered data.

Usage example

gp = GnuplotScript()

M = rand(10,3)

id = register_data(gp, M)

free_form(gp,"replot $id u 1:2")
free_form(gp,"replot $id u 1:3")
source
GnuplotScripting.set_titleMethod
set_title(gp::GnuplotScript,title::AbstractString;
                   enhanced::Bool = false)

Define plot title. If enhanced is true, some characters are processed in a special way. By example _ subscripts text.

source
GnuplotScripting.write_scriptMethod
write_script(script_file::AbstractString,gp::GnuplotScript)

Write script with embedded data for future use.

Usage

gp = GnuplotScript()

...

write_script("gnuplot_script.gp",gp)

You can replay the script using Gnuplot:

    gnuplot gnuplot_script.gp

If you want to keep the gnuplot session opened, add a final -

    gnuplot gnuplot_script.gp -
source