Skip to content

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'
replot
console
$ foresight pe02_terminals.gp && ls pe02*
foresight: pe02.txt
pe02.html
pe02.pdf
pe02.svg
pe02.txt
pe02_terminals.gp
pe02
open SVG ↗

pe02.pdf, pe02.html.

Why it works ​

gnuplot's terminalforesight writes
svgSVG, its texts by font name or drawn from the compiled-in glyphs (fontglyphs)
pdfcairo, pdfPDF with its fonts embedded (path C)
cairolatexa LaTeX picture and its PDF (C6)
dumb, blocktext, 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, postscriptnot available: an error naming the terminal
  • The options are gnuplot's (size, font, linewidth, dashlength, rounded, standalone, ...); theme NAME is foresight's.
  • replot draws 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 output without set terminal picks 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.

foresight is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT (License).