Docstrings updated
This commit is contained in:
parent
65bfe5050f
commit
bd950c2209
@ -221,8 +221,13 @@ save(term="gif animate size 480,360 delay 5", output="assets/animation.gif")
|
|||||||
When gnuplot commands are passed to `@gp` or `@gsp` they are stored in a session for future use, or to be saved in [Gnuplot scripts](@ref). If you simply wish to execute a command, without storing it in the session, use [`gpexec`](@ref). E.g. if you wish to temporarily change the current terminal:
|
When gnuplot commands are passed to `@gp` or `@gsp` they are stored in a session for future use, or to be saved in [Gnuplot scripts](@ref). If you simply wish to execute a command, without storing it in the session, use [`gpexec`](@ref). E.g. if you wish to temporarily change the current terminal:
|
||||||
```@repl abc
|
```@repl abc
|
||||||
gpexec("set term wxt");
|
gpexec("set term wxt");
|
||||||
|
```
|
||||||
|
The gnuplot process replies are returned as a string, e.g.:
|
||||||
|
```@repl abc
|
||||||
|
gpexec("print GPVAL_TERM")
|
||||||
gpexec("set term unknown") #hide
|
gpexec("set term unknown") #hide
|
||||||
```
|
```
|
||||||
|
|
||||||
You may also provide a session ID as first argument (see [Multiple sessions](@ref), to redirect the command to a specific session.
|
You may also provide a session ID as first argument (see [Multiple sessions](@ref), to redirect the command to a specific session.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ This page collects useful tips in using **Gnuplot.jl**.
|
|||||||
## Which terminal should I use ?
|
## Which terminal should I use ?
|
||||||
Gnuplot provides dozens of terminals to display plots or export them into files (see [`terminals()`](@ref) to get a list of enabled terminals on your platform). This section discuss a few tips on how to use the most common terminals.
|
Gnuplot provides dozens of terminals to display plots or export them into files (see [`terminals()`](@ref) to get a list of enabled terminals on your platform). This section discuss a few tips on how to use the most common terminals.
|
||||||
|
|
||||||
To use a specific terminal for interactive use you may either add it as initialization command for all new session with (see [Options](@ref):
|
To use a specific terminal for interactive use you may either add it as initialization command for all new session with (see [Options](@ref)):
|
||||||
```julia
|
```julia
|
||||||
push!(Gnuplot.options.init, "set term wxt")
|
push!(Gnuplot.options.init, "set term wxt")
|
||||||
```
|
```
|
||||||
@ -14,6 +14,7 @@ or directly send the command to a specific session (see [Direct command executio
|
|||||||
```julia
|
```julia
|
||||||
gpexec("set term wxt")
|
gpexec("set term wxt")
|
||||||
```
|
```
|
||||||
|
See official [gnuplot documentation](http://gnuplot.sourceforge.net/documentation.html) for further info on terminals and their options.
|
||||||
|
|
||||||
|
|
||||||
### Interactive terminals (`wxt` and `qt`)
|
### Interactive terminals (`wxt` and `qt`)
|
||||||
@ -44,13 +45,52 @@ The `dumb` terminal uses ASCII characters to draw a plot, while `sixel` and `six
|
|||||||
|
|
||||||
The above terminals are available if gnuplot has been compiled with the `--with-bitmap-terminals` option enabled. Also, `sixelgd` requires support for Libgd to be enabled.
|
The above terminals are available if gnuplot has been compiled with the `--with-bitmap-terminals` option enabled. Also, `sixelgd` requires support for Libgd to be enabled.
|
||||||
|
|
||||||
|
|
||||||
### Export to image files
|
### Export to image files
|
||||||
|
|
||||||
### `cairopng`
|
Gnuplot provides dozens of terminals able to export on files. Examples are:
|
||||||
|
- `cairopng` to export PNG files;
|
||||||
|
- `pdfcairo` for PDF;
|
||||||
|
- `jpeg` for JPG;
|
||||||
|
- `gif` for GIF (see [Animations](@ref)).
|
||||||
|
|
||||||
### `gif`
|
All the above terminals support the `size` and `fontscale` options to quickly adjust the size of the rasterized image and of the font respectively. E.g.:
|
||||||
see [Animations](@ref).
|
```julia
|
||||||
|
save(term="pngcairo size 480,360 fontscale 0.8", output="output.png")
|
||||||
|
```
|
||||||
|
(see also [`save()`](@ref)).
|
||||||
|
|
||||||
### `pdf`
|
Gnuplot is also able to export vector (i.e. non-raster) plots through the `svg` terminal.
|
||||||
|
|
||||||
### `latex` and `cairolatex`
|
Finally, the `cairolatex` terminal allows to produce high quality plots by splitting the output into a PDF file (containing a rasterized image of a plot) and a `.tex` file (containing all the text as ``\LaTeX`` code). The following example shows how to write plot tics and an equation in ``\LaTeX``:
|
||||||
|
```julia
|
||||||
|
x = LinRange(-2pi, 2pi, 1000)
|
||||||
|
|
||||||
|
|
||||||
|
@gp t="Polynomial approximation of sin(x)" "set style fill transparent solid 0.6 noborder"
|
||||||
|
@gp :- raw"""set xtics ('$-\pi$' -pi, '$-\pi/2$' -pi/2, 0, '$\pi/2$' pi/2, '$\pi$' pi)"""
|
||||||
|
@gp :- xr=3.8.*[-1, 1] yr=[-1.5,1.5] key="box opaque left horiz" linetypes(:Blues_3) "set grid front"
|
||||||
|
latex = raw"""\begin{minipage}[c]{\textwidth}\begin{equation*} \sin(x) = \sum_0^{+\infty} \frac{(-1)^n}{(2n + 1)!} x^{2n+1} \end{equation*} \end{minipage}"""
|
||||||
|
@gp :- "set label at graph 0.62,0.2 front center '$latex'"
|
||||||
|
@gp :- x sin.(x) x "w filledcurve t 'n=0' lt 1"
|
||||||
|
@gp :- x sin.(x) x .- x.^3/6 "w filledcurve t 'n=1' lt 2"
|
||||||
|
@gp :- x sin.(x) x .- x.^3/6 .+ x.^5/120 "w filledcurve t 'n=2' lt 3"
|
||||||
|
@gp :- x sin.(x) x .- x.^3/6 .+ x.^5/120 .- x.^7/5040 "w filledcurve t 'n=3' lt 4"
|
||||||
|
@gp :- x sin.(x) "w l t 'sin(x)' lw 2 lc rgb 'black'"
|
||||||
|
save(term="cairolatex pdf input color dashed size 5in,3.3in", output="test.tex")
|
||||||
|
```
|
||||||
|
The two output files (`test.tex` and `test.pdf`) can then be included in a ``\LaTeX`` file as follows:
|
||||||
|
```latex
|
||||||
|
\documentclass{article}
|
||||||
|
\usepackage{amsmath}
|
||||||
|
\usepackage{graphicx}
|
||||||
|
\usepackage{color}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
\begin{figure}
|
||||||
|
\input{test.tex}
|
||||||
|
\end{figure}
|
||||||
|
\end{document}
|
||||||
|
```
|
||||||
|
And the output is:
|
||||||
|

|
||||||
|
|||||||
@ -1340,24 +1340,24 @@ terminal(sid::Symbol=options.default) = gpexec(getsession(sid), "print GPVAL_TER
|
|||||||
|
|
||||||
Run the `test` and `test palette` commands on a gnuplot terminal.
|
Run the `test` and `test palette` commands on a gnuplot terminal.
|
||||||
|
|
||||||
If no `term` is given it will use the default terminal. If `linetypes` and `palette` are given they are used as input to the [`linetypes`](@ref) and [`palette`](@ref) function repsetcively to load the associated color scheme.
|
If no `term` is given it will use the default terminal. If `lt` and `pal` are given they are used as input to the [`linetypes`](@ref) and [`palette`](@ref) function repsetcively to load the associated color scheme.
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
```julia
|
```julia
|
||||||
test_terminal()
|
test_terminal()
|
||||||
test_terminal("wxt", linetypes=:rust, palette=:viridis)
|
test_terminal("wxt", lt=:rust, pal=:viridis)
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function test_terminal(term=nothing; linetypes=nothing, palette=nothing)
|
function test_terminal(term=nothing; lt=nothing, pal=nothing)
|
||||||
quit(:test_term)
|
quit(:test_term)
|
||||||
quit(:test_palette)
|
quit(:test_palette)
|
||||||
if !isnothing(term)
|
if !isnothing(term)
|
||||||
gpexec(:test_term , "set term $term")
|
gpexec(:test_term , "set term $term")
|
||||||
gpexec(:test_palette , "set term $term")
|
gpexec(:test_palette , "set term $term")
|
||||||
end
|
end
|
||||||
s = (isnothing(linetypes) ? "" : linetypes(linetypes))
|
s = (isnothing(lt) ? "" : linetypes(lt))
|
||||||
gpexec(:test_term , "$s; test")
|
gpexec(:test_term , "$s; test")
|
||||||
s = (isnothing(palette) ? "" : palette(palette))
|
s = (isnothing(pal) ? "" : palette(pal))
|
||||||
gpexec(:test_palette , "$s; test palette")
|
gpexec(:test_palette , "$s; test palette")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user