4D plotting in Gnuplot
Home
4D Gnuplot
Gnuplot-Latex
Gnuplot movie
Gnuplot symbols
Gnuplot can plot 4D plots i.e. with usual 3D plotting, it can provide independent color axis representing another dimension. For this to work,
you have to have data files printed in a special way. Suppose you have 2D grid of coordinates (x1, x2, x3, ...) , (y1, y2, y3, ...), and a z-axis that is a function of x and y. Let us assume that the functional values in those points are (g00,g11,g10, ..), i.e. the data is arranged like
x | y | z | variable |
x0 | y0 | f(x0,y0) | g00 |
x0 | y1 | f(x0,y1) | g01 |
x0 | y2 | f(x0,y2) | g02 |
x1 | y0 | f(x1,y0) | g10 |
x1 | y1 | f(x1,y1) | g11 |
x1 | y2 | f(x1,y2) | g12 |
x2 | y0 | f(x2,y0) | g20 |
x2 | y1 | f(x2,y1) | g21 |
x2 | y2 | f(x2,y2) | g22 |
Here, f(x,y) is the z-coordinate. It is better if this coordinate is unique. In case of multiple values of z, the figure becomes too much crowded.
The gxy values you can put by hand or generated by a code.
(Note that, this single line spacing is very crucial for such plots). Now plot the data file using the command
set pm3d
sp "filename.dat" u 1:2:3:4 w pm3d
.
Here is an example of a datafile datafile.tab
=======================================================================================