8.12 Color maps
Color maps provide a graphical means of producing two-dimensional representations of
surfaces, or equivalently of producing maps of the values
of functions of two variables. Each point in the
plane is assigned a color which indicates the value
associated with that point. In this section, we refer to the third coordinate as
rather than
, to distinguish it from the third axes of three-dimensional plots.
In the following simple example, a color map of the complex argument of the Riemann zeta function
is produced, taking the
plane to be an Argand plane, with
being the real axis, and
being the imaginary axis. Each point in the plane has an associated value of
.
set numerics complex
set nokey
set size 8 square
set samples grid 400x400
set c1range[-pi:pi]
set c1format r"$%s
pi$"%(c/pi)
plot [-20:6][-13:13] arg(zeta(x+i*y)) with colormap
The set c1range command sets the range of values of
to be assigned colors between black and white. By default, the lowest and highest values of
found in the color map is assigned to black and white.
The set c1format command controls the format of the axis labels placed along the color scale bar on the right-hand side of the plot. In this case, they are marked as multiples of
.
The set samples grid command sets the dimensions of the grid of samples – or pixels – used to render the color map. If either value is replaced with an asterisk (*) then the current number of samples set in the set samples command is substituted.
If a data file is supplied to the colormap plot style, then the datapoints need not lie on the specified regular grid, but are first re-sampled onto this grid using the interpolation method specified using the set samples interpolate command (see Section 5.7). Three methods are available. nearestNeighbor uses the value of
associated with the datapoint closest to each grid point, producing color maps which look like Voronoi diagrams. inverseSquare interpolation returns a weighted average of the supplied data points, using the inverse squares of their distances from each grid point as weights. monaghanLattanzio interpolation uses the weighting function of Monaghan & Lattanzio (1985) which is described further in Section 5.7).
In the following example, a color map of a quadrupole is produced using four input datapoints:
set nokey
set size 8 square
set samples grid 200x200 interpolate inverseSquare
plot [-4:4][-4:4] ’–’ with colormap
-1 -1 1
-1 1 -1
1 -1 -1
1 1 1
END