Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 10 How to do it... The following script will create the previous figure: term pngcairo dashed out 'xsquared.png' samples 6 key top left for [n = 1 : 4] arrow from first n, 0 to first n, n**2 back \ nohead lt 7 set for [n = 1 : 4] arrow from first 0, n**2 to first n, n**2 back \ nohead lt 7 set for [n = 0 : 5] ytics (n**2) plot [0:5] x**2 with linespoints pt 7 ps 3 set set set set set How it works... We have included explicit set terminal and set out commands because we want our linetype specifications to select a dashed line; if you prefer to use colored lines where the figure has a dashed line, you can omit the dashed keyword. We set a small number of samples because we want to illustrate the technique with a handful of points, that typically might be read from a datafile. After placing the legend in the top-left corner where it will not collide with the data, we use iteration to define two sets of four arrows. The coordinates of their starting and ending positions are taken from the positions of the tic marks and the function that we plan to plot.