![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |
In order to plot several data those are stored in one file, use using and index. Here, "data" means a set of XY pairs. Gnuplot draws one line or prints the same symbol at each data-point.
When those data have the same X-values, prepare the data in a table format, and use the using option to specifiy Y-data. The next example file contains three Y-values at the same X-value.
![]() When the X-values are different, the whole data are separated into several blocks, and put two blank lines between the each block. (Note: here we use the term "block" for a set of data points in a general meaning, and this is different from the gnuplot's definition of "datablock". The datablock in gnuplot is a set of data points separated by a single blank line.)
![]()
![]() As you can see above, all the data in the different data blocks are drawn by the same line/symbol type. To make them different, specify a data block by index . The first data block has an index of zero, the second is one, and so on.
![]() You can specify the range of index. For example, to use the same symbol for the first and second blocks, and change the symbol for the third block:
![]() |
You can make some simple calculations and change the data of the column which is specified by the using option. With the following data we show four cases simultaneously --- Y-values themselves, Y-values are doubled, squared, and logarithm is taken.
![]() Specify the n-th column by $n , and make some operation. The expression should be put into parenthesis. An expression like using 1:sqrt($2) does not work. You can also make some calculations which need several columns. For example, using 1:($2*$3) makes a product of the second and third columns. Sometimes this technique is useful when you have a data file which contains Y-value uncertainties, and the uncertainties are represented by a relative error (%). To draw error bars your data uncertainties should be absolute. To convert from relative uncertainties into absolute ones, using 1:($2*$3/100.0), where the second column is the Y-data, and the third column is the percent errors. |
Gnuplot uses two files, one is the data and another is the control command. If your data are not so complicated, you can put the plot command into one file together with the data themselves. Basically it is the same as a usual command file, but the data file to be plotted is not an external one but it is just "-", and the numerical data follow. Gnuplot stops reading the data when a line begins with the letter "e".
Prepare a control file which includes the data just like above, and give the name as a command line option when gnuplot is invoked.
By the way, you cannot use the replot command in this method. Gnuplot tries to read the data from the standard input again, because Gnuplot does not remember the data. |
There are two ways to skip some data in a data file -- the first one is to edit the data file, alternatively you can use the every option. To skip some points in your data by editing the data file, put some letter like "?" just before the number. This letter is defined by the set missing command, but any kinds of letters which cannot be converted into numbers work too. The next example is to draw graphs of (X,Y1) and (X,Y2).
In the left drawing, the second X value has "?" mark, so that the second data points (2.0,1.8) and (2.0,0.8) are skipped. In the right drawing, the point (2.0,1.8) still is alive, but (2.0,0.8) is erased.
![]()
![]() This function is useful if you want to alter the range of plot in a table formatted data. Let's plot the following data in log-scale, the second (Y1) and the third (Y2) columns are plotted simultaneously.
The Y1-values are zero in the X range of [1:3], so you cannot take log here. Gnuplot produces a vertical line at the lowest point which has a positive value (here, that is X=4). ![]() To remove this vertical line, put "?" at Y1=0.0, like "?0.0". Then the Y1 data (the red line) are treated as that they begin at X=4. The same thing you can do with the plot command option every ::3 . See the next topic. ![]() |
![]() | |
![]() |
![]() ![]() ![]() ![]() |
![]() |