E2. Terminals and outputs
Goal: the outputs foresight writes, through gnuplot's terminals: the same plot as an image, a page, a PDF and text.
gnuplot
# one plot, every output: each `set terminal` and `set output`, then `replot`
set title 'Damped oscillation'
set xlabel 't [s]'
set samples 300
set terminal svg size 600,320
set output 'pe02.svg'
plot [0:10] exp(-x/4)*cos(3*x) title 'response', exp(-x/4) title 'envelope' dt 2
set terminal html size 600,320
set output 'pe02.html'
replot
set terminal pdfcairo size 12cm,6.4cm
set output 'pe02.pdf'
replot
set terminal dumb size 70,20
set output 'pe02.txt'
replotconsole
$ foresight pe02_terminals.gp && ls pe02*
foresight: pe02.txt
pe02.html
pe02.pdf
pe02.svg
pe02.txt
pe02_terminals.gpWhy it works
| gnuplot's terminal | foresight writes |
|---|---|
svg | SVG, its texts by font name or drawn from the compiled-in glyphs (fontglyphs) |
pdfcairo, pdf | PDF with its fonts embedded (path C) |
cairolatex | a LaTeX picture and its PDF (C6) |
dumb, block | text, with characters or Unicode blocks, in ANSI colors if asked |
html (foresight's) | an interactive page: zoom, pan, hover, hidden series, live reload |
canvas, pngcairo, png, qt, wxt, x11, epslatex, postscript | not available: an error naming the terminal |
- The options are gnuplot's (
size,font,linewidth,dashlength,rounded,standalone, ...);theme NAMEis foresight's. replotdraws the last plot again on the new terminal and output, gnuplot's way of writing several formats.- The layout is the same on every device: texts are measured with the fonts' metrics, so the SVG, the PDF and the page place every label at the same point.
Try this
set terminal svg fontglyphs: the SVG draws its texts from the embedded glyphs, the same on every machine.set terminal block braille ansi: the plot in Braille dots, colored, for a terminal over ssh.
Pitfalls
set outputwithoutset terminalpicks the format from the extension in foresight, not in gnuplot: name the terminal for a script that runs in both.- A PNG is not written: raster output is out of foresight's scope; convert an SVG or a PDF if a raster is needed.
Reference: Output Formats. Next: E3. What foresight adds.