diff --git a/dev/advanced/index.html b/dev/advanced/index.html index 8268c7f..2fc9655 100644 --- a/dev/advanced/index.html +++ b/dev/advanced/index.html @@ -16,16 +16,16 @@ name = "\$MyDataSet1" a = gpexec("print a"), b = gpexec("print b"), c = gpexec("print c"))
┌ Info: Best fit values:
-│ a = "1.49027843564636"
-│ b = "0.291241150034077"
-└ c = "0.712856583575748"A named dataset is available until the session is reset, i.e. as long as :- is used as first argument to @gp.
Gnuplot.jl can draw multiple plots in the same figure by exploiting the multiplot command. Each plot is identified by a positive integer number, which can be used as argument to @gp to redirect commands to the appropriate plot.
Continuing previous example we can plot both data and best fit model (in plot 1) and residuals (in plot 2):
@gp :- "set multiplot layout 2,1"
+│ a = "1.52455657762681"
+│ b = "0.263740767002851"
+└ c = "0.709597164355116"A named dataset is available until the session is reset, i.e. as long as :- is used as first argument to @gp.
Gnuplot.jl can draw multiple plots in the same figure by exploiting the multiplot command. Each plot is identified by a positive integer number, which can be used as argument to @gp to redirect commands to the appropriate plot.
Continuing with the previous example we can plot both data and best fit model (in plot 1) and residuals (in plot 2):
@gp :- "set multiplot layout 2,1"
@gp :- 1 "p $name w errorbars t 'Data'"
@gp :- "p $name u 1:(f(\$1)) w l t 'Best fit model'"
@gp :- 2 "p $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars t 'Resid. [{/Symbol s}]'"
@gp :- [extrema(x)...] [0,0] "w l notit dt 2 lc rgb 'black'" # reference line
Note that the order of the plots is not relevant, i.e. we would get the same results with:
@gp :- "set multiplot layout 2,1"
@gp :- 2 "p $name u 1:((f(\$1)-\$2) / \$3):(1) w errorbars t 'Resid. [{/Symbol s}]'"
@gp :- [extrema(x)...] [0,0] "w l notit dt 2 lc rgb 'black'" # reference line
-@gp :- 1 "p $name w errorbars t 'Data'"
+@gp :- 1 "p $name w errorbars t 'Data'"
@gp :- "p $name u 1:(f(\$1)) w l t 'Best fit model'"A multiplot can also mix 2D and 3D plots:
x = y = -10:0.33:10
@gp "set multiplot layout 1,2"
@@ -38,7 +38,7 @@ fxy = [sinc2d(x,y) for x in x, y in y]
@gsp :- 2 x y fxy "w pm3d notit"
Gnuplot.jl can handle multiple sessions, i.e. multiple gnuplot processes running simultaneously. Each session is identified by an ID (sid::Symbol, in the documentation).
In order to redirect commands to a specific session simply insert a symbol into your @gp or @gsp call, e.g.:
@gp :GP1 "plot sin(x)" # opens first window
@gp :GP2 "plot sin(x)" # opens secondo window
@gp :- :GP1 "plot cos(x)" # add a plot on first windowThe session ID can appear in every position in the argument list, but only one ID can be present in each call. If the session ID is not specified the :default session is considered.
The names of all current sessions can be retrieved with session_names():
julia> println(session_names())
-Symbol[:default, :GP1, :GP2]To quit a specific session use Gnuplot.quit():
julia> Gnuplot.quit(:GP1)
+[:default, :GP1, :GP2]To quit a specific session use Gnuplot.quit():
julia> Gnuplot.quit(:GP1)
0The output value is the exit status of the underlying gnuplot process.
You may also quit all active sessions at once with Gnuplot.quitall():
julia> Gnuplot.quitall()Gnuplot.jl provides facilities to compute and display histograms, through the hist() function. E.g., to quickly preview an histogram:
x = randn(1000);
@gp hist(x)
A finer control on the output is achieved by setting the range to consider (range= keyword) and either the bin size (bs=) or the total number of bins (nbins=) in the histogram. See hist() documentation for further information.
Moreover, the hist() return a Gnuplot.Histogram1D structure, whose content can be exploited to customize histogram appearence, e.g.:
x = randn(1000);
h = hist(x, range=3 .* [-1,1], bs=0.5)
@@ -47,14 +47,14 @@ y = randn(10_000)
@gp "set size ratio -1" hist(x, y)
Again, a finer control can be achieved by specifying ranges, bin size or number of bins (along both dimensions) and by explicitly using the content of the returned Gnuplot.Histogram2D structure:
h = hist(x, y, bs1=0.25, nbins2=20, range1=[-3,3], range2=[-3,3])
@gp "set size ratio -1" h.bins1 h.bins2 h.counts "w image notit"
Alternatively, 2D histograms may be displayed using the boxxyerror plot style which allows more flexibility in, e.g., handling transparencies and drawing the histogram grid. In this case the data can be prepared using the boxxyerror() function, as follows:
box = boxxyerror(h.bins1, h.bins2, cartesian=true)
@gp "set size ratio -1" "set style fill solid 0.5 border lc rgb 'gray'" :-
-@gp :- box... h.counts "w boxxyerror notit lc pal"
Although gnuplot already handles contours by itself (with the set contour command), Gnuplot.jl provides a way to calculate contour lines paths before displaying them, using the contourlines() function. We may use it for, e.g., plot contour lines with customized widths and palette, according to their z level. Continuing previous example:
clines = contourlines(h.bins1, h.bins2, h.counts, cntrparam="levels discrete 10, 30, 60, 90");
+@gp :- box... h.counts "w boxxyerror notit lc pal"
Although gnuplot already handles contours by itself (with the set contour command), Gnuplot.jl provides a way to calculate contour lines paths before displaying them, using the contourlines() function. We may use it for, e.g., plot contour lines with customized widths and palette, according to their z level. Continuing with the previous example:
clines = contourlines(h.bins1, h.bins2, h.counts, cntrparam="levels discrete 10, 30, 60, 90");
for i in 1:length(clines)
@gp :- clines[i].data "w l t '$(clines[i].z)' lw $i lc pal" :-
end
@gp :- key="outside top center box horizontal"
The Multiplot capabilities can also be used to stack plots one above the other in order to create an animation, as in the following example:
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 "set xyplane at 0" "unset colorbox" cb=[-1,1] zr=[-1,1]
+@gsp "set xyplane at 0" "unset colorbox" cbr=[-1,1] zr=[-1,1]
frame = 0
for direction in [-1,1]
for factor in -1:0.1:1
@@ -92,4 +92,4 @@ 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.Settings
This document was generated with Documenter.jl on Thursday 2 April 2020. Using Julia version 1.3.1.