Skip to content

Images, palettes and 3D ​

Images and palettes, 3D plots, views, contours, gridded surfaces and voxels. Part of the gnuplot subset reference.

Images and palettes ​

gnuplot
set cblabel 'phi'
plot 'field.dat' u 1:2:3 w image t 'phi(x,y)'
cb_image
open SVG ↗

with image colors a regular grid of values (a heatmap): x:y:z points, evenly spaced in x and y (one per pixel centre, missing points left transparent), or a matrix file, the values of each row along x, the rows along y. The x and y axes fit the pixel edges, half a pixel beyond the first and last centres, never extended to the ticks, as gnuplot. Undefined values are transparent. On a nonlinear axis the pixels are drawn one by one at their mapped edges, as gnuplot's pixels.

gnuplot's binary data arrays are read too: plot 'file' binary array=(W,H) [format='%uchar...'] [flipx] [flipy] [flip=x|y] [dx=DX] [dy=DY] [origin=(X,Y)] [center=(X,Y)] [rotation=A] [skip=N] [endian=little|big] with rgbimage (or image, rgbalpha, any style): W x H pixels, a scan line after the other, the first at the bottom unless flipped, pixel (i, j) at origin + (i dx, j dy) (dx alone sets dy too); center moves the image's natural centre there; rotation (rotate, rot: radians, 30d degrees, 0.5pi multiples of pi) turns the pixels about that centre, or about the origin when origin is given, as gnuplot's; a right angle keeps them a grid, any other angle draws each pixel as the polygon of its corners (colored by the palette or its packed RGB; its key entry a filled box, where gnuplot's has none). Each pixel's fields as the format (%char, %uchar, %short, %ushort, %int, %uint, %long, %ulong, %float, %double and the sized names %int8 ... %float64; %*type reads a field and skips it; one specifier for every field, floats by default; rgbimage reads 3, rgbalpha 4, or as many as the using reads). using addresses the fields (using ($1+$2+$3) with image), the x and y of the pixels implied. The matrix binary and the general binary records are in Binary files. A one-dimensional array (array=W) in a 2D plot generates x alone: using 1 is the y (plot 'sine.bin' binary array=201 dx=0.01 format='%f' using 1 with lines); the type names take gnuplot's short forms too (%f, %lf, %d, %byte, ...).

A splot's image in a 3D view (not set view map) draws each pixel as a 3D polygon, colored by the palette over the set cbrange (or its packed RGB), as gnuplot's: in the plane z = 0, or at the z of center=(X,Y,Z) or origin=(X,Y,Z); perpendicular=(PX,PY,PZ) (perp, splot only) turns the image so that its normal lies along that vector, as gnuplot's rotation_matrix_3D (perp=(1,0,0): the image in the plane x = its centre, its second axis along y). The pixel centres autoscale the axes, as gnuplot's image points. Not supported: filetype= (png, ...), per-record lists of skip= and origin= (skip=360:348), and an autoscaled cbrange for 3D images (set it); a 3D image has no color box.

The palette maps the values over cbrange (autoscaled to the values and, a linear one with its color box drawn, extended to its ticks; noextend, set autoscale cbfix or unset colorbox keeps the values) to colors, as gnuplot 6.0 (its test palette values): the default rgbformulae 7,5,15 (black, blue, red, yellow), any of the 37 rgbformulae (a negative number for the formula of 1 - gray), defined (0 "blue", 1 "white", 2 "red") interpolated in RGB (colors #rrggbb, 0xrrggbb or one of gnuplot's 111 color names), cubehelix (Dave Green's helix through the color cube, lightness rising with gray: start S its starting hue, cycles C its turns, saturation S; gnuplot's 0.5, -1.5, 1, reset at each cubehelix, the options right after it), file 'f' (a gradient read from a data file, see below), gray, viridis, or a named palette; color (after gray) restores the last one set by rgbformulae, defined, viridis or a name, else the default; negative reverses it, maxcolors N quantizes it to N bands. The color box at the right of the plot shows the palette over the range, with cblabel. The palette colors only images and the color box: the series colors (lc N) are the linetype colors.

gnuplot
set palette viridis maxcolors 10
set xlabel 'sweep'; set ylabel 'block'; set cblabel 'residual'
plot 'blocks.dat' matrix w image notitle
cb_matrix
open SVG ↗

In SVG and HTML an image is an embedded PNG, its pixels kept sharp at any zoom; the HTML page zooms it with the data. In text each character takes the pixel at its centre, denser for brighter pixels ( .:-=+*#%@), in its color with ansi. The vfd and lcd themes replace the default palette with their own: with vfd, the dark glass for the lowest values up to the emissive colors, and maxcolors turns the heatmap into a grid of lit levels; washi and night keep it.

cb_image_vfd
open SVG ↗

set palette file 'f' reads a gradient as gnuplot: 4 columns gray:r:g:b (the grays increasing, mapped to 0..1 as defined), or 3 columns r:g:b evenly spaced (the default is 4 columns when the rows have a 4th), the components from 0 to 1 (clipped); index, every and using (expressions too) select and compute them as in plot, # comments are skipped and a blank line is an error. Words before the file keep their effect (set palette negative then set palette file 'f' stays negative), words after it apply to it. From the library, set_palette_gradient takes the positions and colors as arrays.

gnuplot
set palette file 'terrain.dat'
set cbrange [-1:1]; set cblabel 'height'
plot 'field.dat' u 1:2:3 w image notitle
cb_palette_file
open SVG ↗

The color axis takes the x and y settings: set cbtics (step, start, end; a factor on a log axis), set format cb (a bare set format reaches it too, set format xy does not), unset cbtics (no ticks nor labels on the box). set logscale cb maps log10 of the values: autoscaled, the axis spans the positive values (3 to 700, not widened to decades), and values <= 0 take the low end color, as gnuplot; its decades are labelled 10 with an exponent, as the log x and y axes.

gnuplot
set logscale cb; set cblabel 'residual'
set cbtics 10
plot 'field.dat' u 1:2:(10**(3*$3)) w image notitle
cb_logcb
open SVG ↗

set colorbox places the box as gnuplot: vertical (the default) at the right of the plot, low values at the bottom (invert: at the top); user in the box of origin X,Y and size W,H, fractions of the whole page from its bottom left (0.9,0.2 and 0.05,0.6 by default), over the plot if so placed; noborder without its frame. horizontal puts low values at the left, the tick labels and cblabel below: at its default place the box lies below the x labels, as wide as the plot (gnuplot keeps the narrow vertical slot there: a horizontal box needs user in gnuplot), and invert changes nothing, as gnuplot. A bare set colorbox returns the box to its default place, the other options kept; unset colorbox resets them all.

gnuplot
set colorbox horizontal
set colorbox vertical user origin 0.86,0.3 size 0.02,0.45 invert
cb_colorbox
open SVG ↗

Not supported: functions palettes, set palette gamma (1.5), set palette model other than RGB, set colorbox back and border line types, pm3d.

with rgbimage (using x:y:r:g:b) and with rgbalpha (x:y:r:g:b:a) color the pixels of a regular grid directly, the components from 0 to set rgbmax (255; 1.0 for fractions), without palette nor color box; an undefined component makes its pixel transparent. One column of packed 32-bit ARGB values (using 1:2:3, 0xAARRGGBB) gives the four components, the alpha inverted as gnuplot's (AA 0 opaque, FF transparent). matrix RGB data are not supported.

Named palettes ​

A foresight extension (gnuplot rejects these scripts): set palette NAME takes one of the 40 Scientific colour maps (v8.0.1) by Fabio Crameri, one of matplotlib's magma, inferno, plasma, viridis, cividis, or Kenneth Moreland's black_body, the name in any case (batlow, BATLOW, romao). They are perceptually uniform (equal steps in value look like equal steps in color), readable with color-vision deficiencies and, the sequential ones, in black-and-white print. A table of 256 colors, gray g takes its color nint(255 g); negative reverses it, and maxcolors N takes the N colors nint(255 k / (N - 1)), Crameri's discrete palettes (batlow maxcolors 10 is his batlow10; a few of his differ by 4/255 at most).

TypeNamesFor
Sequentialacton bamako batlow batlowK batlowW bilbao buda davos devon glasgow grayC hawaii imola lajolla lapaz lipari navia naviaW nuuk oslo tokyo turku; magma inferno plasma viridis cividis black_bodya magnitude, low to high
Divergingbam berlin broc cork lisbon managua roma tofino vanimo vika deviation from a meaningful centre (zero, a mean): set a cbrange symmetric about it
Multi-sequentialbukavu fes olerontwo regimes either side of a value at mid-palette (depth and height about sea level): set a cbrange that puts the value in the middle
CyclicbamO brocO corkO romaO vikOa periodic quantity (phase, angle, direction, time of day): both ends have the same color
cb_colormaps_all
open SVG ↗
gnuplot
set palette vik
set cbrange [-1:1]
plot 'field.dat' u 1:2:3 w image notitle

Their 22 categorical orders (actonS ... turkuS) color series instead: set colorsequence batlowS 6, see Styles.

Credit the Scientific colour maps as Crameri, F. (2018), Scientific colour maps, Zenodo, doi:10.5281/zenodo.1243862, and see Crameri, Shephard and Heron (2020), The misuse of colour in science communication, Nature Communications 11, 5444, doi:10.1038/s41467-020-19160-7. cividis is Nuñez, Anderton and Renslow (2018), Optimizing colormaps with consideration for color vision deficiency to enable accurate interpretation of scientific data, PLoS ONE 13(7), e0199239, doi:10.1371/journal.pone.0199239, in the version its author gave matplotlib. The Scientific colour maps are MIT-licensed, magma, inferno, plasma and viridis CC0, cividis under matplotlib's licence and Battelle's, black_body CC0: the notices are in src/lib/foresight_colormaps.F90.

3D plots ​

splot plots items with a height: data with three using fields x:y:z, functions of x and y, matrices, the pseudo-files. As in gnuplot 6.0, the data of an item are scans, its blocks separated by blank lines (each dataset, two blank lines apart, a surface of its own); a function of x and y is sampled on its iso-curves, set isosamples N,M (10 by default): M curves of y, the surface grid, of set samples points along x each, then N curves of x; a matrix has a scan per row (x the column number, y the row number from 0, or with nonuniform its first row and column); a single column is the z of the point and scan numbers. The using fields are those of plot with the z third: using 1:2:3:4 with labels (x:y:z:text), using 1:2:3:4:5:6 with vectors (the z delta read and ignored by the map view), using 1:2:3 with points lc palette (colored by z unless a column follows), using 1:2:3 with image (x:y:value, or x:y:z:value).

gnuplot
set view map
set isosamples 30, 30
set xrange [-3:3]; set yrange [-3:3]
splot x*exp(-x**2-y**2) with points pt 7 ps 0.5 lc palette

using N alone reads the heights from column N, x the point number in its scan and y the scan number in its dataset, as gnuplot. Inline ranges are [x] [y] [z]; the dummy variables are x and y (set dummy u, v renames them; [NAME=a:b] names them for the plot, splot [x=-3:3] [y=-3:3] sin(x)*cos(y)). set table writes the surfaces as gnuplot does: a block # Surface K of N surfaces per dataset of each item, its grid iso-curves (the scans of data last first, gnuplot's order), rows x y z type. set view, set xyplane, set ticslevel, set zrange, set zlabel, set ztics, set mztics, set zzeroaxis and set surface set the 3D views. An autoscaled z axis spans the heights of the points within the x and y ranges set, as gnuplot's (a point outside them does not count).

with pm3d draws a surface as colored quadrangles, gnuplot's pm3d: each pair of neighbouring scans joined point by point, each quadrangle in the palette color of its corners (set pm3d corners2color, their mean by default; with a fourth using field, of its values; lc variable too), subdivided by set pm3d interpolate N,M; the color box spans the data's z (or color) range. With lc rgb variable (or fc rgb variable) the fourth field is a packed color 0xAARRGGBB (without one, the heights are the colors, as gnuplot) and a quadrangle takes the mean of its corners channel by channel (c1 ... c4: one of them; a surface of 2 scans takes them in reverse order, as gnuplot's scansautomatic); the color box then spans z. set pm3d border outlines each quadrangle after its fill. set pm3d alone draws every surface with pm3d under its own lines (unset surface leaves the pm3d alone), set style function pm3d and set style data pm3d the items without with. In a map view the base, surface and top (at b|s|t) are the same picture, but for the z range set: a quadrangle needs a corner within it (as within the x and y ranges set), and at the surface alone (at s) gnuplot's clip z cuts it at the range's ends, each piece in the color of its whole quadrangle; the color axis autoscales over the points within the ranges. set pm3d depthorder draws a map's quadrangles from the highest down (gnuplot's map is seen from below), and set wall puts its walls behind it.

gnuplot
set view map
set pm3d interpolate 4,4
set isosamples 30, 30
splot sin(x)*cos(y) with pm3d notitle

3D views ​

gnuplot
set view 70, 120, 1, 1.2       # rot_x, rot_z, scale, z scale
set xyplane at 0               # the base plane at z = 0 (default: half the z range below it)
set border 4095                # the whole box
set xlabel 'x'; set ylabel 'y'; set zlabel 'z'
splot sin(x)*cos(y) title 'surface'

A splot without set view map is drawn in a 3D view as gnuplot 6.0 draws it (graph3d.c, util3d.c), positions to its terminal unit: the box of the x, y and z ranges turned by set view ROT_X, ROT_Z (60, 30 by default: rot_x about the horizontal axis, then rot_z about the vertical one), scaled by SCALE and the z axis by SCALE_Z, set view azimuth A turning it about the line of sight; set view equal xy (xyz) gives x and y (and z) the same unit. set view projection xz (yz) shows the xz (yz) plane edge-on as gnuplot's fixed rotations (270, 0 and 90, 90, the scale 1.425 times the map's, the line of sight turned by -90 degrees, the yz plane's z axis reversed): x (y) vertical and z horizontal, the base plane at the bottom of the z range, the plane's border with the ticks on its four sides, the z tick labels centred below it, the x (y) label left of its tick labels (the y label rotated as in 2D); set label and set arrow positions in graph x and y (z 0) are read on the plane, the x fraction along z. set xlabel rotate by A, rotate and rotate parallel (along the projected axis) turn the axis labels of a 3D view, the y label one in the yz projection only, as gnuplot's. The base plane lies below the z range by half of it (set xyplane relative F, set ticslevel F) or at a height (set xyplane at Z). set border bits 1 to 4095 draw the base edges (1 to 8), the verticals (16 to 128; an unset one goes from the base to the surface's corner, as gnuplot's) and the top edges (256 to 2048); the default 31 is the base and the vertical at the z axis. The x and y ticks lie along the front edges of the base (the back ones beyond rot_x 90), mirrored on the opposite edges, their labels beside them; the z ticks at the left corner, labels at their left (set ztics mirror at the right corner too); in, out, axis and the tick scales as in 2D. The axis labels sit beyond the tick labels (the z label seven characters left of the z axis), the title above the box, the key at the top right of the plot. set grid draws the x and y grid on the base (set grid vertical on the back walls too, set grid ztics the z levels); set xzeroaxis, set yzeroaxis and set zzeroaxis the zero lines. Lines, linespoints, points, dots and labels are drawn in the view, a data grid (scans of one length) as a mesh of its scans and the curves across them, lines clipped to the box, points outside it dropped; impulses rise from z = 0 (the z range then includes it). set multiplot places the views in gnuplot's cells. The HTML page shows a 3D view as drawn (no zoom, no pan; a map view zooms as a 2D plot); the dumb and block devices draw it with their own text layout. set label, set arrow and set object positions take a third coordinate (at x, y, z; z 0 when absent): axis values are projected as the data, graph ones are fractions of the x, y and z axes, screen and character ones are page positions as in 2D; a circle's radius in x units is scaled as gnuplot's (the x axis length on the page). set mapping spherical reads splot's data as theta:phi:r (x = r cos theta cos phi, y = r sin theta cos phi, z = r sin phi), set mapping cylindrical as theta:z:r (x = r cos theta, y = r sin theta), r 1 when the data have two columns, the angles in the set angles unit; functions are not mapped (set parametric draws a sphere of them).

The key of a 3D view lies where gnuplot's do_3dkey_layout puts it: inside at the top right by default (left, bottom move it), below the plot (which rises by its rows), outside at the right or left (the plot narrowed by its width); at places it as in 2D. Its entries are graph3d's, in a map view too: each sample 4 characters and a tick long (0.7 of the font size a character), a character from its title (before it with reverse), the fill samples half an entry high (0.75 of the font size above and below the row's centre), as gnuplot's svg draws them.

set hidden3d removes the hidden lines by a painter's algorithm, not gnuplot's hidden3d.c: each grid surface (lines or linespoints of a function or of scans of one length) is drawn as quadrangles filled with the page color and stroked, painted from the farthest; a quadrangle seen from below (its scans in gnuplot's order) takes the surface's underside color, the linetype after its own (offset N; nooffset the same; gnuplot reserves that linetype, the next item taking the one after). A function is then sampled on its isosamples grid both ways, without crossing curves. Points, labels, other lines and the box are not hidden by the surfaces (gnuplot hides them); trianglepattern, undefined, altdiagonal, bentover, front, back are read. unset hidden3d draws the meshes again. Measured against gnuplot 6.0 over the 11 demos mixing set hidden3d and pm3d (2026-11-26): the painter's departure costs one page, hidden2's first (0.038 on the fidelity scale, 0 identical, 1 opposite), where set hidden3d front draws a mesh over a pm3d surface with only its own hidden lines removed; the other pages differ for other reasons. A port of hidden3d.c (about 2300 lines) is not scheduled for it (decision D2 of the 3D plan).

splot ... with lines smooth csplines|acsplines smooths each scan in 3D as gnuplot's gen_3d_splines: a scan in a plane of constant x is splined as z of y, of constant y as z of x, of constant z as y of x, from its first point to its last in set samples points; any other as x, y and z of its path length; acsplines weighs the points by a fourth using field (1 without).

In a 3D view pm3d draws the surface as colored quadrangles projected on the page, gnuplot's pm3d_plot: at the surface, the base plane and the top of the box (set pm3d at s|b|t, combined and drawn in that order: at bstbst); in gnuplot's order of the scans and of their points (scansautomatic, the default: from the depths of the first and last points of a scan and of the first scan, as pm3d_rearrange_part; scansforward, scansbackward: over gnuplot's list of the scans, a data file's last first, a function's in sampling order), each surface in its place among the items (a surface of set pm3d just before its own lines); with depthorder the quadrangles of every surface are sorted by their mean depth and drawn after all the items (depthorder base: by the depth of the base below them). The color box stands beside the plot at gnuplot's default place for 3D views (from 0.709 to 0.778 of the view's x scale right of its middle).

set pm3d lighting shades the quadrangles at the surface as gnuplot's apply_lighting_model: the ambient light, a primary light from 45 and 85 degrees fixed with respect to the viewer (primary F, 0.5 by default), its Phong highlights (specular F, 0.2) and a colored spotlight on the faces turned away (spec2 F, none by default; set pm3d spotlight rot_x A rot_z B rgbcolor C Phong P, gnuplot's 50, 90, 0xff0044, 4), on the palette colors, lc rgb variable and a fill color alike (fc "gray", fc ls N that of line style N, fc lt N that of linetype N); the color box keeps the palette. nolighting turns it off.

The quadrangles at the surface are clipped to the z range (gnuplot's default set pm3d clip z): a z range set cuts them smoothly at its ends, as clip_filled_polygon (clip1in draws those with a corner in range whole, clip4in those with all 4); the color axis autoscales over the points within the ranges set, those of every item of the plot (lines, points, boxes, polygons, labels: their heights, gnuplot's plot3d) once the palette colors something. splot ... with contourfill draws the pm3d surface in slices of z, gnuplot's plot3d_contourfill: for each slice in turn (set contourfill auto N: N equal slices of the z range; ztics, cbtics: from each major tick within it to the next, the first and last reaching its ends) the quadrangles clipped to it, each slice in the palette color of its middle (firstlinetype N: of linetypes N, N+1, ...), lit by set pm3d lighting, outlined by set pm3d border, sorted with depthorder by the depth of their quadrangle; in a 3D view or a map, its contours left to set contour items (gnuplot draws none of its own). At the base and the top (at b, t) the slices are drawn clipped too (gnuplot draws every quadrangle whole there, slice after slice). With set hidden3d the mesh of a pm3d surface is hidden by it, its lines not drawn over it (gnuplot draws the visible segments of the mesh on top).

splot ... with boxes draws gnuplot's 3D boxes (plot3d_boxes): for each point a face from z = 0 (within the z range) to its height, as wide as set boxwidth (1 without), in the y = constant plane of the point; with set boxdepth D a box D deep along y (square: as deep as wide on the page) with its back, sides and top, the y range autoscaled over y - D to y + D about each point (gnuplot's plot3d). Each in the point's color (lc variable, fc rgb variable, lit by set pm3d lighting) or the item's fill color, in its fill style and border (black unless its color is given); an item's faces are sorted by the depth of their base, or with set pm3d depthorder base with every pm3d surface. The key sample is the fill alone.

splot ... with polygons draws a polygon per block of the data (gnuplot's plot3d_polygons): in the first point's color (lc variable, fc rgb variable) or its fill color, lit by set pm3d lighting, outlined by set pm3d border; an item's polygons are sorted by their depth, or with set pm3d depthorder with every pm3d surface and the depthorder polygon objects (set object N polygon ... depthorder: closed, in their fill style, line style N+1's color on the back of fc ls N, gnuplot's 2-sided coloring). The depth-sorted polygons keep each its item's fill style and outline (a box its fill border), a pattern in the polygon's own color, its lines as wide as the border (gnuplot's svg tile inherits the line width in effect). A polygon of 3 corners is gnuplot's quadrangle with its first corner again; an object of more than 11 corners is not drawn. Its key entry is the title alone, as gnuplot's.

splot ... with zerrorfill draws a line with its z errors, gnuplot's plot3d_zerrorfill: between each two points a quadrangle from their low ends to their high ones (x:y:z:dz from z - dz to z + dz, or x:y:z:zlow:zhigh), in the item's fill color (fc, else its line color), then the line through z: with fc in its line color, else in its fill's border color (black by default, fs border lc C, the background with noborder: gnuplot's colors "backwards"); fs and set style fill give its fill. The key sample is the fill crossed by the line. The quadrangles of an item are sorted by depth among themselves and later items cover earlier ones (gnuplot's: plot them back to front), or with set pm3d depthorder sorted with every pm3d surface. set wall puts gnuplot's grid walls in a 3D view: polygons over the planes of the graph (y0, x0, y1, x1, z0), filled half transparent in gnuplot's colors, bordered in black, unless fs and fc are given, each drawn behind the plot when it faces away and over it when it faces the viewer; unset wall removes them.

Contours ​

gnuplot
set view map
set pm3d at b; unset surface          # the pm3d map, the surface lines not drawn (their contours are)
set contour base
set cntrparam levels incremental -0.75, 0.5, 0.75
splot sin(x)*cos(y) lw 2 title 'sin(x) cos(y)'

set contour draws the contour lines of every surface, a port of gnuplot 6.0's contour.c: each grid cell split into two triangles, the lines traced through them (from the grid's boundary first, then the closed ones), in linear segments (set cntrparam linear, the default), through a cubic spline (cubicspline) or approximated by a B-spline (bspline order N), points N per spline interval. The levels are about N round values within the heights (levels auto N, 5 by default: gnuplot's tick step), the values given (discrete), or from start by step (incremental). Each level is drawn in its own linetype, the surface's next ones (firstlinetype N the first), with a key entry its value in the set cntrlabel format ("%8.3g"); set cntrlabel onecolor draws them all in the surface's color, without key entries. As gnuplot's, the levels of an untitled surface have no key entries, and the contours of a with pm3d item are not stroked. set table writes them as gnuplot does (# Contour N, label: L, the levels high first, lines in chunks of at most 99 points); 2D scripts read them back (plot $CONTOURS with lines). unset surface keeps the contours, nocontours and nosurface select per item. In a 3D view the lines of set contour base lie on the base plane, those of surface at their heights, both with both (the key entries once), as gnuplot's graph3d; they are not hidden by the surfaces of set hidden3d.

A surface with labels (a function, or data without a text field: using 1, using 1:2:3) draws the labels of its contour lines alone, as gnuplot's cntr3d_labels: each level's text at the points start, start + interval, ... of every line (set cntrlabel start 5 interval 20 by default), centred, boxed with the item, on the base plane of a 3D view; splot f(x,y) with lines, f(x,y) with labels boxed notitle draws the contours and their values.

Gridded and masked surfaces ​

gnuplot
set view map
set dgrid3d 50,50 gauss 0.6                       # the scattered points gridded, a Gaussian kernel
set table $HULL
plot 'points.dat' using 1:2 convexhull with lines # the hull of the points, a polygon
unset table
splot $HULL using 1:2:(0) with mask, 'points.dat' using 1:2:3 mask with pm3d

set dgrid3d turns the scattered data of every splot item into a grid, a port of gnuplot 6.0's grid_nongrid_data: COLS iso-curves of x, ROWS points along y each, over the points' bounding box; each node is a weighted mean of the points, by the inverse distance to the power Q (qnorm Q, the default with Q 1; a point on a node gives its value), a kernel of the distance scaled by DX, DY (gauss, cauchy, exp, box, hann: a node out of every point's reach is undefined) or the thin plate splines through them (splines); kdensity keeps the kernel's weighted sums, a density of the points (using 1:2:(1)). The grid is drawn and tabulated as any surface (set table writes it as gnuplot does); functions, nogrid items and masks are not gridded; unset dgrid3d stops it.

with mask reads polygons (blocks of x, y; a polygon need not be closed) that are not drawn: an item with the mask option is drawn only inside them, gnuplot's even-odd interior test. A pm3d quadrangle is kept when its first corner is inside a polygon, an image pixel when its far corner is; without a with mask item nothing is masked. The last with mask item of a plot is the mask; its key entry is its title alone.

The map view (set view map) is drawn as gnuplot 6.0 draws it: its plot area is the projection of the x and y ranges (gnuplot's 3D layout, narrower than a 2D plot's: set view map scale S scales it), ticks inward on all four sides with lengths by the projection, the tick labels, axis labels, title, key and color box at gnuplot's map places (the color box a character width farther right than a 2D plot's, its ticks on both sides). The items keep their plot styles: points, lines, labels, vectors, images (with image, from data x:y:value, x:y:z:value or a matrix), lc palette by z, ps variable, pt variable. The HTML page zooms a map as a 2D plot; the text devices draw it with their own layout (gnuplot's dumb map is not followed). The other views are 3D views. set parametric surfaces are triples x(u,v), y(u,v), z(u,v) sampled on the urange, vrange iso-curves; the inline ranges of a parametric splot are gnuplot's [u] [v] [x] [y] [z] (splot [u=0:1] [v=-5:5] ..., the names renaming the dummy variables for the plot). In the library, fig%splot(x, y, z) adds scattered points (a scan; gridded after set_dgrid3d) and fig%splot(x, y, z2d) a grid z(i, j) at (x(i), y(j)), a scan per row; set_zrange, set_zlabel, set_ztics set the z axis, set_view and set_xyplane the view.

Voxel grids ​

gnuplot 6.0's voxel grids, as its voxelgrid.c and vplot.c:

gnuplot
set vgrid $helix size 33                      # a 33 x 33 x 33 grid of zeros, the active one
set vxrange [-2:2]; set vyrange [-2:2]; set vzrange [0:11]
vfill sample [t=0:20] '+' using (cos($1)):(sin($1)):($1):(0.9):(10.0)
splot $helix with points pt 7 ps 0.4 lt 2, $helix with isosurface level 1.0 lt 3
CommandEffect
set vgrid $NAME [size N]a grid of N x N x N zeros (N from 10 to 256, 100 by default; an existing grid keeps its size and values), made the active one
set vxrange [a:b], vyrange, vzrangethe active grid's ranges; without them, the fixed xrange, yrange, zrange when the grid is first used, else an error
unset vgrid $NAMEthe grid freed
vclear [$NAME]every value zero (the active grid by default)
voxel(x,y,z) = vthe grid point of (x, y, z): indices ceil((x - min) / delta), as gnuplot; out of the ranges a warning
voxel(x,y,z)in an expression, the value there (NaN out of the ranges, an error without an active grid)
vfill source using x:y:z:radius:(density)for each data point in the ranges, the density added to every grid point within the radius (and to the nearest one always); VoxelDistance (and GridDistance, in grid steps) its distance while the density is evaluated; any plot source and option (sample [t=a:b] '+', datablocks, files, '-')
vgfill ...the same, the radius in grid steps
set isosurface [mixed|triangles] [insidecolor N|noinsidecolor]the isosurface facets: quadrangles and triangles (gnuplot's default) or triangles only; the inside color is read
splot $NAME with points|dots [above L]the grid points of values above L (0 by default; dots without a style), lc palette colored by their value
splot $NAME with isosurface level Lthe surface of level L by marching cubes (gnuplot's tables), its facets filled in the item's line color and the fill style, depth sorted with set pm3d depthorder

The grid's ranges autoscale the axes, as gnuplot's. exists("VoxelDistance") is true, the test gnuplot's demos make. Values are single precision, as gnuplot's. Not supported: the inside color of an isosurface (its back faces are drawn in the same color), a key sample for an isosurface, show vgrid (a no-op, as every show).

foresight is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT (License).