Three-dimensional Plots
Prev | Chapter 3. Advanced Use of PLplot | Next

## Three-dimensional Plots

PLplot includes three-dimensional plot routines that plot functions of the two independent variables `x` and `y` in a variety of ways (see the section called “Surface Plots”, the section called “Contour Plots”, the section called “Shade plots”, the section called “Image plots”, and the section called “Vector plots”).

### Surface Plots

PLplot provides the routines `plmesh`, `plmeshc`, `plot3d`, `plot3dc`, `plot3dcl`, `plsurf3d`, `plsurf3dl` and `plfill3` to plot the projection of a 3D surface on an existing 2D window. Our standard examples 08, 11, 15, 21, and 28 illustrate how these routines are used.

In all cases the transformations required to plot the projection of a 3D surface on a 2D window are configured by `plw3d` and are done to a rectangular cuboid enclosing the 3D surface which has its limits expressed in 3D world coordinates and also normalized 3D coordinates (used for interpreting the altitude and azimuth of the viewing angle). This representation of the transformation process allows considerable flexibility in specifying how the surface is depicted. The lengths of the sides of the normalized rectangular cuboid are independent of the 3D world coordinate ranges of each of the variables, making it possible to use “reasonable” viewing angles even if the ranges of the 3D world coordinates on the axes are very different. The size of the normalized rectangular cuboid is determined essentially by the size of the two-dimensional window into which it is to be mapped. The normalized cuboid is centered about its origin in the `x` and `y` directions, but rests on the plane `z = 0`. It is viewed by an observer located at altitude `alt` and azimuth `az`, where both angles are measured in degrees. The altitude should be restricted to the range zero to ninety degrees for proper operation, and represents the viewing angle above the xy plane of the normalized cuboid. The azimuth is defined so that when `az = 0`, the observer sees the xz plane face on, and as the angle is increased, the observer moves clockwise around the normalized cuboid as viewed from above the xy plane. The azimuth can take on any value. In the above list of examples, we have chosen x and y world-coordinate ranges near (-1.0-1.0) for the 2D window, and x, y, z sizes of the normalized cuboid near (1., 1., 1.), and users will likely want to adopt similar values as well.

### Contour Plots

PLplot provides the `plcont` routine for generating contour plots and our standard examples 08, 14, 16, and 22 illustrate how this routine is used. The contourer uses a contour-following algorithm so that it is possible to use non-continuous line styles. Further, one may specify arbitrary coordinate mappings from array indices to world coordinates, such as for contours in a polar coordinate system.

The path of each contour is initially computed in terms of the values of the indices of the matrix that holds the data to be contoured. Before these can be drawn in the current window (see the section called “Defining the Window”), it is necessary to convert from these array indices into world coordinates. This transformation is normally done by a callback function which is supplied as an argument to `plcont`. For C use of `plcont` we have included directly in the PLplot library the following transformation callback routines: `pltr0` (identity transformation); `pltr1` (linear interpolation in singly dimensioned coordinate arrays); and `pltr2` (linear interpolation in doubly dimensioned coordinate arrays), but other callbacks can be used for the C case instead. The above list of examples illustrates how this callback argument and associated transformation from index arguments to world coordinates is implemented in each of our supported languages.

### Shade plots

PLplot provides the `plshade` and `plshades` routines for generating shade plots and our standard examples 15, 16, 21, and 22 illustrate how those routines are used including how the needed transformation from index arguments to world coordinates is implemented in each of our supported languages.

### Image plots

PLplot provides the `plimage` and `plimagefr` routines for generating images plots and our standard example 20 illustrates how those routines are used including how the needed transformation from index arguments to world coordinates is implemented in each of our supported languages.

### Vector plots

PLplot provides the `plvect` routine for generating vector plots and our standard example 22 illustrates how that routine is used including how the needed transformation from index arguments to world coordinates is implemented in each of our supported languages. In addition that routine shows how to call `plsvect` to set the arrow style for vector plots.

Prev | Up | Next
Setting Character Attributes | Home | Legends and color bars