C1. A first PDF
Goal: a figure a paper takes as it is, written by foresight itself: no converter, no gnuplot.
gnuplot
set title "Residual history"
set xlabel "iteration"
set ylabel "residual"
set logscale y
set format y "10^{%L}"
set output 'pc01.pdf'
plot [1:200] exp(-x/30) title "Jacobi", exp(-x/12) dt 2 title "multigrid"console
$ foresight pc01_first_pdf.gpThe output's extension picks the format: set output 'pc01.pdf' in a script, call fig%save('pc01.pdf') from Fortran. pc01.pdf is the figure above as a PDF of one page, 600x480 px at 96 px to the inch (450x360 pt), the size of the SVG.
Why it works
- The PDF device draws every primitive of the SVG device: lines (dashes, widths, joins), filled polygons with their opacity and gnuplot's fill patterns, markers, error bars, arrowheads, images (8-bit RGB with their alpha), readouts, and text with gnuplot's enhanced markup (
10^{%L}above: a superscript placed and sized as in the SVG). - The layout is the one of every device: texts are measured with the compiled-in fonts' metrics, so the PDF and the SVG place every label at the same point.
- The file is written in one piece, uncompressed and without dates: the same figure gives the same bytes, a figure under version control changes only when the plot does.
Try this
- Add
set key bottom left boxand compare the two outputs. - Write the same figure from Fortran:
call fig%save('residual.pdf')after theplotcalls of the first chapter.
Pitfalls
- A PDF shows what is drawn, not the viewer: hidden series, zoom and hover texts are the HTML page's.
- The fonts travel with the file (the next chapter): a journal's checker finds them embedded.