1
votes

I recently stumbled upon an example where Gnuplot produces (at least for me) an unexpected result so I was wondering whether it is indeed the desired behavior. The setup is following:

set terminal pngcairo
set output plot3d?"plot1.png":"plot0.png"

unset key
set xtics nomirror
set ytics nomirror
set xr [0.5:2.5]
set yr [-0.5:4.5]

set multiplot layout 1,2

$data0 << EOD
1   2   1
2   4   1
1   3   1


1   0   1
2   2   1
1   1   1
EOD

$data1 << EOD
1   2   1
2   4   1
1   3   1

1   0   1
2   2   1
1   1   1
EOD


if(plot3d){
    set view map
    splot $data0 w lp, \
        '' u 1:2:3:(sprintf("%d", $0)) w labels offset char 0, char -0.5

    splot $data1 w lp, \
        '' u 1:2:3:(sprintf("%d", $0)) w labels offset char 0, char -0.5
}else{
    plot $data0 w lp, \
        '' u 1:2:(sprintf("%d", $0)) w labels offset char 0, char -0.5

    plot $data1 w lp, \
        '' u 1:2:(sprintf("%d", $0)) w labels offset char 0, char -0.5
}

The two data blocks differ only in white space, $data0 has two blank lines, while $data1 just one. With plot3d=1, the script produces (5.0 patchlevel 6) enter image description here

Interestingly, also points 1 and 4 in data block $data1 are connected. This edge seems to disappear when the empty line is commented out. Digressing to plot (plot3d=0) yields an expected result: enter image description here

I am probably missing something obvious, although the documentation seems to state that (perhaps it's somehow overridden by splot):

Single blank records designate discontinuities in a plot; no line will join points separated by a blank records (if they are plotted with a line style).

1

1 Answers

1
votes

Yes, the behaviour you describe is correct for splot. Indeed, the quote you show explicitely mentions plot and not splot. For splot behaviour see the documentation for "splot > data-file", where it says:

Single blank records separate datablocks in a splot datafile; splot treats datablocks as the equivalent of function y-isolines. No line will join points separated by a blank record. If all datablocks contain the same number of points, gnuplot will draw cross-isolines between datablocks, connecting corresponding points. This is termed "grid data",...

So, in general, single blank lines are used to structure gridded data for splot or to allow selecting data points and data blocks using every.

Two blank lines always have the same meaning to separate two data sets, which can be selected with index.