diff --git a/dev/advanced/index.html b/dev/advanced/index.html index 0cdae86..f3e4126 100644 --- a/dev/advanced/index.html +++ b/dev/advanced/index.html @@ -1,2 +1,12 @@ -
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
+@gp "set multiplot layout 1,2"
+@gp :- 1 "plot sin(x) w l"
+
+
+x = y = -10:0.33:10
+fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
+fxy = [fz(x,y) for x in x, y in y]
+
+@gsp :- 2 x y fxy "w pm3d notit"
+Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
Gnuplot.@gp — Macro@gp args...
The @gp macro (and its companion @gsp, for splot operations) allows to exploit all of the Gnuplot package functionalities using an extremely efficient and concise syntax. Both macros accept the same syntax, as described below.
The macros accepts any number of arguments, with the following meaning:
$ sign: a data set name;Int > 0: the plot destination in a multiplot session;$ sign (i.e. the data set name);:- symbol, used as first argument, avoids resetting the Gnuplot session. Used as last argument avoids immediate execution of the plot/splot command. This symbol can be used to split a single call into multiple ones.All entries are optional, and there is no mandatory order. The plot specification can either be:
The list of accepted keyword is as follows:
title::String: plot title;xlabel::String: X axis label;ylabel::String: Y axis label;zlabel::String: Z axis label;xlog::Bool: logarithmic scale for X axis;ylog::Bool: logarithmic scale for Y axis;zlog::Bool: logarithmic scale for Z axis;xrange::NTuple{2, Number}: X axis range;yrange::NTuple{2, Number}: Y axis range;zrange::NTuple{2, Number}: Z axis range;cbrange::NTuple{2, Number}: Color box axis range;The symbol for the above-mentioned keywords may also be used in a shortened form, as long as there is no ambiguity with other keywords. E.g. you can use: xr=(1,10) in place of xrange=(1,10).
Examples:
Simple examples with no data:
@gp "plot sin(x)"
+API · Gnuplot.jl API
The list of Gnuplot.jl exported symbols are as follows:
Gnuplot.@gp — Macro@gp args...
The @gp macro (and its companion @gsp, for splot operations) allows to exploit all of the Gnuplot package functionalities using an extremely efficient and concise syntax. Both macros accept the same syntax, as described below.
The macros accepts any number of arguments, with the following meaning:
- a symbol: the name of the session to use;
- a string: a command (e.g. "set key left") or plot specification (e.g. "with lines");
- a string starting with a
$ sign: a data set name; - an
Int > 0: the plot destination in a multiplot session; - a keyword/value pair: a keyword value (see below);
- any other type: a dataset to be passed to Gnuplot. Each dataset must be terminated by either:
- a string starting with a
$ sign (i.e. the data set name); - or a string with the plot specifications (e.g. "with lines");
- the
:- symbol, used as first argument, avoids resetting the Gnuplot session. Used as last argument avoids immediate execution of the plot/splot command. This symbol can be used to split a single call into multiple ones.
All entries are optional, and there is no mandatory order. The plot specification can either be:
- a complete plot/splot command (e.g., "plot sin(x)", both "plot" and "splot" can be abbreviated to "p" and "s" respectively);
- or a partial specification starting with the "with" clause (if it follows a data set).
The list of accepted keyword is as follows:
title::String: plot title;xlabel::String: X axis label;ylabel::String: Y axis label;zlabel::String: Z axis label;xlog::Bool: logarithmic scale for X axis;ylog::Bool: logarithmic scale for Y axis;zlog::Bool: logarithmic scale for Z axis;xrange::NTuple{2, Number}: X axis range;yrange::NTuple{2, Number}: Y axis range;zrange::NTuple{2, Number}: Z axis range;cbrange::NTuple{2, Number}: Color box axis range;
The symbol for the above-mentioned keywords may also be used in a shortened form, as long as there is no ambiguity with other keywords. E.g. you can use: xr=(1,10) in place of xrange=(1,10).
Examples:
Simple examples with no data:
@gp "plot sin(x)"
@gp "plot sin(x)" "pl cos(x)"
@gp "plo sin(x)" "s cos(x)"
@@ -70,4 +70,4 @@ save(term="pdf", output="gnuplot.pdf")
sourceSettings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
+@gp "set size square" img "u 2:(-\$1):3:4:5 with rgbimage" # Correct orientationGnuplot.@gsp — Macro@gsp
See documentation for @gp.
Gnuplot.save — Functionsave(...)
Save the data and commands in the current session to either:
save(term="", output="");save(stream::IO; term="", output="");save(file::AbstractStrings; term="", output="").To save the data and command from a specific session pass the ID as first argument, i.e.:
save(sid::Symbol, term="", output="");save(sid::Symbol, file::AbstractStrings; term="", output="").In all cases the term keyword allows to specify a gnuplot terminal, and the output keyword allows to specify an output file.
Missing docstring for palette. Check Documenter's build log for details.
Missing docstring for linestyles. Check Documenter's build log for details.
Missing docstring for hist. Check Documenter's build log for details.
Missing docstring for contourlines. Check Documenter's build log for details.
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
The main purpose of the Gnuplot.jl package is to send data and commands to the underlying gnuplot process, in order to generate plots. Unlike other packages, however, the actual commands to plot, or the plot attributes, are not specified through function calls. This is what makes Gnuplot.jl easy to learn and use: there are no functions or keywords names to memorize[1].
The most important symbols exported by the package are the @gp (for 2D plots) and @gsp (for 3D plots) macros, both accepting any number of arguments, and whose meaning is interpreted as follows:
one, or a group of consecutive, array(s) build up a dataset. The different arrays are accessible as columns 1, 2, etc. from the gnuplot process. The number of required input arrays depends on the chosen plot style (see gnuplot documentation);
a string occurring before a dataset is interpreted as a gnuplot command (e.g. set grid);
a string occurring immediately after a dataset is interpreted as a plot element for the dataset, by which you can specify using clause, with clause, line styles, etc.;
the special symbol :-, whose meaning is to avoid creating a new plot (if given as first argument), or to avoid immediately running all commands to create the final plot (if given as last argument). Its purpose is to allow splitting one long statement into multiple (shorter) ones.
The above lists all the required concepts to follow the examples presented below. The @gp and @gsp macros also accepts further arguments, but their use will be discussed in Advanced techniques.
Here we will show a few examples to generate 2D plots. The examples are intentionally very simple to highlight the behavior of Gnuplot.jl. See Examples for more complex ones.
gnuplot commands:@gp "plot sin(x)"
+save(term="png size 480,360", output="src/assets/basic1.png") # hide
@gp "set key left" "plot sin(x)" "pl cos(x)"
+save(term="png size 480,360", output="src/assets/basic2.png") # hide
Note that all gnuplot commands can be abbreviated as long as the resulting string is not ambiguous. In the example above we used pl in place of plot.
@gp call in three statements:@gp "set grid" :-
+@gp :- "p sin(x)" :-
+@gp :- "plo cos(x)"
+save(term="png size 480,360", output="src/assets/basic3.png") # hide
gnuplot:@gp (1:20).^2
+save(term="png size 480,360", output="src/assets/basic4.png") # hide
x = 1:20
+@gp "set key left" x ./ 20 x.^2 "with lines tit 'Parabola'"
+save(term="png size 480,360", output="src/assets/basic5.png") # hide
x = 1:0.1:10
+@gp "set grid" "set key left" "set logscale y"
+@gp :- "set title 'Plot title'" "set label 'X label'" "set xrange [0:12]"
+@gp :- x x.^0.5 "w l tit 'Pow 0.5' dt 2 lw 2 lc rgb 'red'"
+@gp :- x x "w l tit 'Pow 1' dt 1 lw 3 lc rgb 'blue'"
+@gp :- x x.^2 "w l tit 'Pow 2' dt 3 lw 2 lc rgb 'purple'"
+save(term="png size 480,360", output="src/assets/basic6.png") # hide
The above example lacks the trailing :- symbol. This means the plot will be updated at each command, adding one curve at a time.
In order to avoid typing long, and very frequently used gnuplot commands, Gnuplot.jl provides a few keywords which can be used in both @gp and @sgp calls:
xrange=[low, high] => "set xrange [low:high];yrange=[low, high] => "set yrange [low:high];zrange=[low, high] => "set zrange [low:high];cbrange=[low, high]=> "set cbrange[low:high];key="..." => "set key ...";title="..." => "set title \"...\"";xlabel="..." => "set xlabel \"...\"";ylabel="..." => "set ylabel \"...\"";zlabel="..." => "set zlabel \"...\"";xlog=true => set logscale x;ylog=true => set logscale y;zlog=true => set logscale z;All such keywords can be abbreviated to unambiguous names.
By using the above keywords the first lines of the previous example:
@gp "set grid" "set key left" "set logscale y"
+@gp :- "set title 'Plot title'" "set label 'X label'" "set xrange [0:12]"can be replaced with a shorter version:
@gp "set grid" k="left" ylog=true
+@gp :- tit="Plot title" xlab="X label" xr=[0,12]Gnuplot.jl can also display images, i.e. 2D arrays:
img = randn(Float64, 30, 50)
+img[10,:] .= -4
+@gp img "w image notit"
+save(term="jpeg size 480,360", output="src/assets/basic7a.png") # hide
Note that the first index corresponds to the X coordinate when the image is displayed.
The following example shows how to fix orientation of an image by means of the using clause (the TestImages package is required to run this example):
using TestImages
+img = testimage("lena");
+@gp "set size square" img "u 2:(-\$1):3:4:5 with rgbimage notit"
+save(term="jpeg size 480,360", output="src/assets/basic7b.jpg") # hide
3D plots follow the same rules as 2D ones, just replace the @gp macro with @gsp and add the required columns (according to the plotting style).
E.g., to plot a spiral increasing in size along the X direction:
x = 0:0.1:10pi
+@gsp x sin.(x) .* x cos.(x) .* x x./15 "w p pt 7 ps var lc pal"
+save(term="jpeg size 640,480", output="src/assets/basic8.jpg") # hide
The keywords discussed above can also be used in 3D plots.
The Gnuplot.jl package comes with all the ColorSchemes palettes readily available.
A gnuplot-compliant palette can be retrieved with palette(), and used as any other command. The previous example may use an alternative palette with:
x = 0:0.1:10pi
+@gsp palette(:viridis) x sin.(x) .* x cos.(x) .* x x./15 "w p pt 7 ps var lc pal"
+save(term="jpeg size 640,480", output="src/assets/basic8a.jpg") # hide
The ColorSchemes palettes can also be used to generate line styles, by means of the linestyles() function, e.g.
@gp linestyles(:deepsea)
+x = 1:0.1:4pi
+for i in 1:5
+ @gp :- x i.* sin.(x) "w l notit ls $i lw 5"
+end
+save(term="jpeg size 480,360", output="src/assets/basic9.jpg") # hide
The save() function allows to export all plots (as well as multiplots, see Multiplot) to a file using one of the many available gnuplot terminals. To check which terminals are available in your platform type set term in your gnuplot terminal.
All plots in this page have been saved with:
save(term="png size 480,360", output="output.png")except the Lena image, saved with the jpeg terminal:
save(term="jpeg size 480,360", output="output.png")Besides exporting plots in a file Gnuplot.jl can also save a script, i.e. a file containing the minimum set of data and commands required to generate a plot within gnuplot.
To generate a script for one of the example above use:
save("script.gp")after the plot has been displayed. The script can then be used within a gnuplot session as follows:
gunplot> load 'script.gp'to generate a plot identical to the original one, without using the Julia language.
The purpose of gnuplot scripts is to allow sharing all data, alongside a plot, in order to foster collaboration among scientists and replicability of results. Moreover, a script can be used at any time to change the details of a plot, without the need to re-run the Julia code used to generate it the first time.
Finally, the scripts are the only possible output when Dry sessions are used (i.e. when gnuplot is not available in the user platform.
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
-@gp "set multiplot layout 1,2"
-@gp :- 1 "plot sin(x) w l"
-
-
-x = y = -10:0.33:10
-fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
-fxy = [fz(x,y) for x in x, y in y]
-
-@gsp :- 2 x y fxy "w pm3d notit"
-@gp "set multiplot layout 1,2" @gp :- 2 "unset grid" "unset border" "unset tics" :- @gp :- 1 "plot sin(x) w l"
x = y = -10:0.33:10 fz(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2) fxy = [fz(x,y) for x in x, y in y]
@gsp :- 2 x y fxy "w pm3d notit"
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
An exhaustive gallery of example is available here:
https://lazarusa.github.io/gnuplot-examples/
Further gnuplot examples can be found here: http://www.gnuplotting.org/
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
The Gnuplot.jl package allows easy and fast use of gnuplot as a data visualization tool in Julia. Have a look at Basic usage and Examples for a quick overview. The package main features are:
fast time-to-first-plot (~1 sec);
extremely concise yet meaningful syntax, makes it ideal for interactive data exploration;
no need to learn new API functions or keywords: only two macros (@gp for 2D plots, @gsp for 3D plots) and a basic knowledge of gnuplot are enough to generate the most complex plots;
transparent interface between Julia and gnuplot to exploit all functionalities of the latter, both present and future ones;
fast data transmission through system pipes (no temporary files involved);
availability of all the palettes from ColorSchemes;
support for multiple plots in one window, mulitple plotting windows, as well as ASCII and Sixel plots (to plot directly in a terminal);
support for histograms (both 1D and 2D);
enhanced support for contour plots;
export to a huge number of formats such as pdf, png, $\LaTeX$, svg, etc. (actually all those supported by gnuplot);
save sessions into gnuplot scripts enables easy plot reproducibility and modfications.
A powerful plottig framework is among the most important tool in the toolbox of any modern scientist and engineer. As such, it is hard to find a single package to fit all needs, and many solutions are indeed available in the Julia ecosystem.
Gnuplot.jl package fills the niche of users who needs:
gnuplot, and its many output formats available;gnuplot documentation, tutorials and examples available on the web;gnuplot knowledge);gnuplot scripts, rather than the original Julia code.Unlike other packages Gnuplot.jl is not a pure Julia solution as it depends on an external package to actually generate plots. However, if gnuplot is not available on a given platform, the package could still be used in "dry" mode, and no error for a missing dependency will be raised (see Dry sessions).
The Gnuplot.jl package development follows a minimalistic approach: it is essentially a thin layer to send data and string commands to gnuplot. This way all underlying capabilities, both present and future ones, are automatically exposed to Julia user, with no need to implement dedicated wrappers.
The functionalities 1, 2 and 3 listed above are similar to those provided by the Gaston package. Gnuplot.jl also provides features 4 and 5, as well as the minimalistic approach.
Any modern plotting package is able to produce a simple scatter plot, with custom symbols, line styles, colors and axis labels. Indeed, this is exactly the example that is reported in every package documentation (also here: see Plots in 2D). Still, producing complex and publication-quality plots is not an easy task. As a consequence is also not easy to determine whether a package can cope with the most difficult cases (unless you actually try it out) and a reasonable choice is typically to rely on the size of the user base, the availability of documentation / tutorials, and the possibility to preview complex examples.
Gnuplot.jl aims to be ready for even the most challenging plots by relying on the widely and long lasting used gnuplot application, and by allowing each native feature (both present and future ones) to be immediately available in the Julia language. Moreover, Gnuplot.jl provides a unique syntax specifically aimed to increase productivity while performing interactive data exploration.
Last but not least, have a look at the Gnuplot.jl Examples page.
In this documentation:
gnuplot refers to the gnuplot application.Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
The Gnuplot.jl package allows easy and fast use of gnuplot as a data visualization tool in Julia. Have a look at Basic usage and Examples for a quick overview. The package main features are:
fast time-to-first-plot (~1 sec);
extremely concise yet meaningful syntax, makes it ideal for interactive data exploration;
no need to learn new API functions or keywords: only two macros (@gp for 2D plots, @gsp for 3D plots) and a basic knowledge of gnuplot are enough to generate the most complex plots;
transparent interface between Julia and gnuplot to exploit all functionalities of the latter, both present and future ones;
fast data transmission through system pipes (no temporary files involved);
availability of all the palettes from ColorSchemes;
support for multiple plots in one window, multiple plotting windows, as well as ASCII and Sixel plots (to plot directly in a terminal);
support for histograms (both 1D and 2D);
enhanced support for contour plots;
export to a huge number of formats such as pdf, png, $\LaTeX$, svg, etc. (actually all those supported by gnuplot);
save sessions into gnuplot scripts enables easy plot reproducibility and modifications.
A powerful plotting framework is among the most important tool in the toolbox of any modern scientist and engineer. As such, it is hard to find a single package to fit all needs, and many solutions are indeed available in the Julia ecosystem.
Gnuplot.jl package fills the niche of users who needs:
gnuplot, and its many output formats available;gnuplot documentation, tutorials and examples available on the web;gnuplot knowledge);gnuplot scripts, rather than the original Julia code.Unlike other packages Gnuplot.jl is not a pure Julia solution as it depends on an external package to actually generate plots. However, if gnuplot is not available on a given platform, the package could still be used in "dry" mode, and no error for a missing dependency will be raised (see Dry sessions).
The Gnuplot.jl package development follows a minimalistic approach: it is essentially a thin layer to send data and string commands to gnuplot. This way all underlying capabilities, both present and future ones, are automatically exposed to Julia user, with no need to implement dedicated wrappers.
The functionalities 1, 2 and 3 listed above are similar to those provided by the Gaston package. Gnuplot.jl also provides features 4 and 5, as well as the minimalistic approach.
Any modern plotting package is able to produce a simple scatter plot, with custom symbols, line styles, colors and axis labels. Indeed, this is exactly the example that is reported in every package documentation (also here: see Plots in 2D). Still, producing complex and publication-quality plots is not an easy task. As a consequence is also not easy to determine whether a package can cope with the most difficult cases (unless you actually try it out) and a reasonable choice is typically to rely on the size of the user base, the availability of documentation / tutorials, and the possibility to preview complex examples.
Gnuplot.jl aims to be ready for even the most challenging plots by relying on the widely and long lasting used gnuplot application, and by allowing each native feature (both present and future ones) to be immediately available in the Julia language. Moreover, Gnuplot.jl provides a unique syntax specifically aimed to increase productivity while performing interactive data exploration.
Last but not least, have a look at the Gnuplot.jl Examples page.
In this documentation:
gnuplot refers to the gnuplot application.Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
In order to use the Gnuplot.jl package you'll need gnuplot (ver. >= 5.0) installed on your system, and its executable available in your path.
In the Julia REPL type:
using Pkg
-Pkg.add("Gnuplot")
-using GnuplotSettings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
In order to use the Gnuplot.jl package you'll need gnuplot (ver. >= 4.7) installed on your system, and its executable available in your path.
If gnuplot is not available in your platform you can still use Gnuplot.jl in "dry" mode (see Dry sessions). In this case a plot can not be generated, but you may still generate Gnuplot scripts.
In the Julia REPL type:
julia> ]add GnuplotThen hit backspace key to return to Julia REPL.
Check execution and version of the underlying gnuplot process:
julia> using Gnuplot
+julia> Gnuplot.gpversion()Generate the first plot:
julia> @gp 1:9Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.
Settings
This document was generated with Documenter.jl on Tuesday 24 March 2020. Using Julia version 1.3.1.