Gnuplot Gotchas – 3D Plots With Nonregular Grid

zurück/back to home

Gnuplot is a great tool for scientific plotting and visualization. However, sometimes it is a bit esoteric and strange to work with.

If you want to plot a surface of regular three dimensional data points with gnuplot as a surface, you might get problems if the data is not equidistent and you do not want gnuplot to extrapolate a surface for you. The key to success is to order the data first by x, then by y and insert a newline after each block with the same y entry. The following first shows two incorrect tries and then the solution.

Points Only

You might first try the following, yielding only some points.

gnuplot output #1

Surface With dgrid3d

You might first try the following, yielding a strangely grid which is interpolated equidistently. Note how this does not resemble our data set at all.

gnuplot output #1

Strangely Interconnected Points

Then, with linespoint, you will get your points strangely interconnected:

gnuplot output #1

The Solution

And finally, we add blank lines between each y-block and get what we want.

gnuplot output #1