API
Index
GnuplotScripting.GnuplotScriptGnuplotScripting.add_vertical_lineGnuplotScripting.export_pngGnuplotScripting.free_formGnuplotScripting.register_dataGnuplotScripting.set_titleGnuplotScripting.write_script
Documentation
GnuplotScripting.GnuplotScript — Typegp = 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
GnuplotScripting.add_vertical_line — Methodadd_vertical_line(gp::GnuplotScript,position::Float64;name::Union{AbstractString,Nothing})Add a vertical bar with a label
GnuplotScripting.export_png — Methodexport_png(gp::GnuplotScript,
filename::AbstractString;
enhanced::Bool)Export the current plots as an PNG image
GnuplotScripting.free_form — Methodfree_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'")GnuplotScripting.register_data — Methodregister_data(gp::GnuplotScript,
data::AbstractVecOrMat;
copy_data::Bool=true) -> idRegister 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")GnuplotScripting.set_title — Methodset_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.
GnuplotScripting.write_script — Methodwrite_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.gpIf you want to keep the gnuplot session opened, add a final -
gnuplot gnuplot_script.gp -