Formatting tic labels
gnuplot provides a great deal of flexibility in the formatting of numbers in tic labels and allows us to freely intermix text with its automatically generated numbers. This is illustrated in the following figure:
How to do it…
The following script introduces the formatting commands that we used to produce the previous figure:
set ylabel "Output power" set format y "P = %.2f Watts" set format x "%.3f%%" set rmargin 6 plot [0:100] x**2
How it works…
The new commands are in the highlighted lines. set format y
and set format x
define the formats to be used for the tic labels on the y and x-axes, respectively. For a complete rundown of all the options, you can type help set format
at the gnuplot interactive prompt. Here, we shall describe the subset of the formatting language that we used in the script. The codes are very similar to those used in many programming languages for the output formatting of numbers.
A formatting specification is introduced by the character %
. It contains...