update 2001/9/12
![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |
Data file "output.dat" contains the calculated values above. Each X-value has 3 different Y values in this case. To draw the second column (calculated EXP(-X) values) as a function of the first column, use using keyword at plotting.
![]() A style of graph is specified by the with keyword. In the above example, lines style is given, with which each data point is connected by small lines. There are several kinds of line-styles those are numbered by 1, 2, 3... To change the line style, with lines is followed by the line-style number. If the number is not given, gnuplot assigns numbers automatically from 1 to a certain maximal number. There are several plot-styles --- draw symbols, connect with lines, connect with step-like lines, draw bars, etc.
|
Next, the third and fourth columns are plotted at the same time. To draw several lines simultaneously, repeat the data specification like -- plot "A" using 1:2 with line, "B" using 1:2 with points, ... Sometimes such a command line becomes very long. If a line is ended with a character '\', the next line is regarded as a continuous line.
![]() The second line shown by green color is negative at the large X values, so that the Y-axis was enlarged to -0.1 In the figure legend, the data-file name and the column numbers those were used for plotting were indicated. The red line is obtained by an analytical function, so let's change the first line of the legend into "Analytical". The next green line is a result of Pade approximation with L=1 and M=2, so that "L=1, M=2" should be displayed. The blue line is also the result of "L=2, M=2" Pade approximation.
![]() |
Now, let's insert X and Y axis names. The name of X axis is just "x", while the Y axis is "y=exp(-x)". To set those names, use the set xlabel and set ylabel commands. In addition, you can write the name of whole figure, "Pade approximation", by the set title command. With the replot command, you can omit a long plot command.
![]() The figure size changed when the title and axis names were given. Gnuplot calculates the figure size automatically so as to draw everything in a screen, then the graph itself becomes smaller when the axis names or figure title are given. The Y axis name "y=exp(-x)" does not go to the left side of the Y-axis, but it is displayed at the top. This is because gnuplot cannot rotate a text when the X Window system is used. With the Postscript terminal you can get a rotated Y-axis name which locates at an appropriate position. |
Now let's change the X and Y ranges. Set the Y-range [0,1], and the X-range [0,2].
![]() |
The graduations on the X-axis starts with 0, and the interval is 0.5. To change the graduations (tics), use set {x|y}tics . The tics can be controlled by three optional numbers. If there is a one number followed the set tics command, like set xtics 10 , this number "10" is regarded as an increment. If there are two figures, the first one is the initial value, and the second is the increment. If three, the last one becomes the final value. You can also divide the interval which is given as an increment by the set tics command, and draw small tics inside the interval with the set m{x|y}tics n command, where n is the number of division.
![]() |
Then we make the graph in a Postscript format, and print it. Firstly change the terminal into "postscript", and specify a name of output file. Before quit gnuplot, save your parameters and other setup into a file ( output.plt )
The file 'output.ps' can be browse with a Postscript viewer like 'gv' or 'ghostview', and you can print this file with a Postscript printer. The following image is our Postscript data 'output.ps' displayed with ghostview. ![]() When you plotted the graph on your screen, the first line was a red line. However it turned into the solid line here. The blue and green lines became the dashed lines. (Though it is hard to see them in a small size image.) As you can see above, line and symbol types depend on the terminal you use. In order to know which line number corresponds to the solid, dashed, dotted, etc. try test . For example, on the X window system, you get:
![]() |
![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |