Docs updated

This commit is contained in:
Giorgio Calderone 2020-04-16 14:24:34 +02:00
parent 6a04709525
commit ad624bebf1

View File

@ -28,9 +28,9 @@ x = range(-2pi, stop=2pi, length=100);
y = sin.(x) y = sin.(x)
name = "\$MyDataSet1" name = "\$MyDataSet1"
@gp name=>(x, y) "plot $name w l lc rgb 'black'" "pl $name u 1:(1.5*\$2) w l lc rgb 'red'" @gp name=>(x, y) "plot $name w l lc rgb 'black'" "pl $name u 1:(1.5*\$2) w l lc rgb 'red'"
saveas("ex010") # hide saveas("advanced010") # hide
``` ```
![](assets/ex010.png) ![](assets/advanced010.png)
Both curves use the same input data, but the red curve has the second column (`\$2`, corresponding to the *y* value) multiplied by a factor 1.5. Both curves use the same input data, but the red curve has the second column (`\$2`, corresponding to the *y* value) multiplied by a factor 1.5.
@ -71,9 +71,9 @@ Continuing with the previous example we can plot both data and best fit model (i
@gp :- "p $name u 1:(f(\$1)) w l t 'Best fit model'" @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 :- 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 :- [extrema(x)...] [0,0] "w l notit dt 2 lc rgb 'black'" # reference line
saveas("ex011") # hide saveas("advanced011") # hide
``` ```
![](assets/ex011.png) ![](assets/advanced011.png)
Note that the order of the plots is not relevant, i.e. we would get the same results with: Note that the order of the plots is not relevant, i.e. we would get the same results with:
```julia ```julia
@ -98,9 +98,9 @@ x = y = -10:0.33:10
sinc2d(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2) sinc2d(x,y) = sin.(sqrt.(x.^2 + y.^2))./sqrt.(x.^2+y.^2)
fxy = [sinc2d(x,y) for x in x, y in y] fxy = [sinc2d(x,y) for x in x, y in y]
@gsp :- 2 x y fxy "w pm3d notit" @gsp :- 2 x y fxy "w pm3d notit"
saveas("ex012") # hide saveas("advanced012") # hide
``` ```
![](assets/ex012.png) ![](assets/advanced012.png)
## Multiple sessions ## Multiple sessions
@ -136,9 +136,9 @@ Gnuplot.quitall()
```@example abc ```@example abc
x = randn(1000); x = randn(1000);
@gp hist(x) @gp hist(x)
saveas("ex013a") # hide saveas("advanced013a") # hide
``` ```
![](assets/ex013a.png) ![](assets/advanced013a.png)
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()`](@ref) documentation for further information. 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()`](@ref) documentation for further information.
@ -147,9 +147,9 @@ The [`hist()`](@ref) return a [`Gnuplot.Histogram1D`](@ref) structure, whose con
x = randn(1000); x = randn(1000);
h = hist(x, range=3 .* [-1,1], bs=0.5) h = hist(x, range=3 .* [-1,1], bs=0.5)
@gp h.bins h.counts "w histep t 'Data' lc rgb 'red'" @gp h.bins h.counts "w histep t 'Data' lc rgb 'red'"
saveas("ex013b") # hide saveas("advanced013b") # hide
``` ```
![](assets/ex013b.png) ![](assets/advanced013b.png)
**Gnuplot.jl** also allows to compute 2D histograms by passing two vectors (with the same lengths) to [`hist()`](@ref). A quick preview is simply obtained by: **Gnuplot.jl** also allows to compute 2D histograms by passing two vectors (with the same lengths) to [`hist()`](@ref). A quick preview is simply obtained by:
@ -157,17 +157,17 @@ saveas("ex013b") # hide
x = randn(10_000) x = randn(10_000)
y = randn(10_000) y = randn(10_000)
@gp "set size ratio -1" hist(x, y) @gp "set size ratio -1" hist(x, y)
saveas("ex014a") # hide saveas("advanced014a") # hide
``` ```
![](assets/ex014a.png) ![](assets/advanced014a.png)
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`](@ref) structure: 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`](@ref) structure:
```@example abc ```@example abc
h = hist(x, y, bs1=0.25, nbins2=20, range1=[-3,3], range2=[-3,3]) 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" @gp "set size ratio -1" h.bins1 h.bins2 h.counts "w image notit"
saveas("ex014b") # hide saveas("advanced014b") # hide
``` ```
![](assets/ex014b.png) ![](assets/advanced014b.png)
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()`](@ref) function, as follows: 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()`](@ref) function, as follows:
@ -175,9 +175,9 @@ Alternatively, 2D histograms may be displayed using the `boxxyerror` plot style
box = boxxyerror(h.bins1, h.bins2, cartesian=true) box = boxxyerror(h.bins1, h.bins2, cartesian=true)
@gp "set size ratio -1" "set style fill solid 0.5 border lc rgb 'gray'" :- @gp "set size ratio -1" "set style fill solid 0.5 border lc rgb 'gray'" :-
@gp :- box... h.counts "w boxxyerror notit lc pal" @gp :- box... h.counts "w boxxyerror notit lc pal"
saveas("ex014c") # hide saveas("advanced014c") # hide
``` ```
![](assets/ex014c.png) ![](assets/advanced014c.png)
## Contour lines ## Contour lines
@ -188,9 +188,9 @@ for i in 1:length(clines)
@gp :- clines[i].data "w l t '$(clines[i].z)' lw $i lc pal" :- @gp :- clines[i].data "w l t '$(clines[i].z)' lw $i lc pal" :-
end end
@gp :- key="outside top center box horizontal" @gp :- key="outside top center box horizontal"
saveas("ex014d") # hide saveas("advanced014d") # hide
``` ```
![](assets/ex014d.png) ![](assets/advanced014d.png)
## Animations ## Animations