---
name: "plgriddata"
section: "3plplot"
platform: "linux"
package: "plplot-doc"
version: "5.15.0+dfsg2-15"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/plgriddata"
---

# plgriddata(3plplot)

Grid data from irregularly sampled data

## NAME

**plgriddata** - Grid data from irregularly sampled data

## SYNOPSIS

**plgriddata**(*x*, *y*, *z*, *npts*, *xg*, *nptsx*, *yg*, *nptsy*, *zg*, *type*, *data*)

## DESCRIPTION

Real world data is frequently irregularly sampled, but PLplot 3D plots require data organized as a grid, i.e., with x sample point values independent of y coordinate and vice versa.  This function takes irregularly sampled data from the x\[npts\], y\[npts\], and z\[npts\] vectors; reads the desired grid location from the input vectors xg\[nptsx\] and yg\[nptsy\]; and returns the interpolated result on that grid using the output matrix zg\[nptsx\]\[nptsy\].  The algorithm used to interpolate the data to the grid is specified with the argument type which can have one parameter specified in argument data.

Redacted form: General: **plgriddata(x, y, z, xg, yg, zg, type, data)** Python: *zg*=**plgriddata(x, y, z, xg, yg, type, data)**

This function is used in example 21.

## ARGUMENTS

- *x* (**PLFLT\_VECTOR**(3plplot), input)

  The input x vector.

- *y* (**PLFLT\_VECTOR**(3plplot), input)

  The input y vector.

- *z* (**PLFLT\_VECTOR**(3plplot), input)

  The input z vector. Each triple x\[i\], y\[i\], z\[i\] represents one data sample coordinate.

- *npts* (**PLINT**(3plplot), input)

  The number of data samples in the x, y and z vectors.

- *xg* (**PLFLT\_VECTOR**(3plplot), input)

  A vector that specifies the grid spacing in the x direction. Usually xg has nptsx equally spaced values from the minimum to the maximum values of the x input vector.

- *nptsx* (**PLINT**(3plplot), input)

  The number of points in the xg vector.

- *yg* (**PLFLT\_VECTOR**(3plplot), input)

  A vector that specifies the grid spacing in the y direction. Similar to the xg parameter.

- *nptsy* (**PLINT**(3plplot), input)

  The number of points in the yg vector.

- *zg* (**PLFLT\_NC\_MATRIX**(3plplot), output)

  The matrix of interpolated results where data lies in the grid specified by xg and yg. Therefore the zg matrix must be dimensioned *nptsx* by *nptsy*.

- *type* (**PLINT**(3plplot), input)

  The type of grid interpolation algorithm to use, which can be: GRID\_CSA: Bivariate Cubic Spline approximation GRID\_DTLI: Delaunay Triangulation Linear Interpolation GRID\_NNI: Natural Neighbors Interpolation GRID\_NNIDW: Nearest Neighbors Inverse Distance Weighted GRID\_NNLI: Nearest Neighbors Linear Interpolation GRID\_NNAIDW:  Nearest Neighbors Around Inverse Distance Weighted For details of the algorithms read the source file plgridd.c.

- *data* (**PLFLT**(3plplot), input)

  Some gridding algorithms require extra data, which can be specified through this argument. Currently, for algorithm: GRID\_NNIDW, data specifies the number of neighbors to use, the lower the value, the noisier (more local) the approximation is. GRID\_NNLI, data specifies what a thin triangle is, in the range \[1. .. 2.\]. High values enable the usage of very thin triangles for interpolation, possibly resulting in error in the approximation. GRID\_NNI, only weights greater than data will be accepted. If 0, all weights will be accepted.

## AUTHORS

Many developers (who are credited at http://plplot.org/credits.php) have contributed to PLplot over its long history.

## SEE ALSO

PLplot documentation at http://plplot.org/documentation.php.
