Plot a 3D matrix as a semitransparent volume
Updated 12 Mar 2015

View License

Note: This function does not yet work for Matlab 2014b or later.
This function plots a 3D data volume as color-scaled semitransparent surface planes in each dimension.

h = pcolor3(...)

pcolor3(V) plots a field of 3D volume V.

pcolor3(X,Y,Z,V) plots 3D volume V at locations given by X,Y,Z. X, Y, and Z can be 3D matrices matching the dimensions of V, or 1D arrays.

pcolor3(...,'alpha',AlphaValue) specifies a volume transparency value between 0 (completely transparent) and 1 (completely opaque). Default AlphaValue is 0.01. This value may seem surprisingly low, but remember that you'll be looking through 100 slices--they add up.

pcolor3(...,'edgealpha',EdgeAlphaValue) specifies transparency of sides of the volume faces of the volume. An EdgeAlphaValue greater than the volume AlphaValue helps define corners and edges, especially in the presence of lighting objects. Default EdgeAlphaValue is 0.05.

pcolor3(...,'alphalim',AlphaLimits) scales transparency values with values of V. This can help highlight a variable of interest by making low V values invisible. AlphaLimits is a two-element array corresponding of values in V. If AlphaLimits is 'auto', AlphaLimits is taken as [min(V(:)) max(V(:))].

Tip: If interesting values diverge about an uninteresting mean (e.g., temperature of 25 is not interesting whereas T = 10 is interesting and T = 40 is also interesting), use 'alphalim',[25 40] and select a colormap that diverges from 25. Although T = 10 is well below the minimum AlphaLimits, 10 and 40 are equidistant from 25 and are therefore given equal opacity.

pcolor3(...,InterpolationMethod) specifies an interpolation method as:

'linear' trilinear slice interpolation (default),
'cubic' tricubic slice interpolation,
'nearest' nearest-neighbor slice interpolation, or
'direct' plots data directly instead of interpolated slices (fastest?).

pcolor3(...,'N',NumberOfSlices) specifies a number of slices in each direction. Default value is 100. Increasing number of slices can make a smoother, higher quality graphic, but may slow performance.

pcolor3(...,'Nx',NumberOfXSlices) specifies a number of slices in the x direction. Default value is 100.

pcolor3(...,'Ny',NumberOfYSlices) specifies a number of slices in the y direction. Default value is 100.

pcolor3(...,'Nz',NumberOfZSlices) specifies a number of slices in the z direction. Default value is 100.

h = pcolor3(...) returns a vector of handles to surface graphics objects.

Cite As

Chad Greene (2024). pcolor3 (https://www.mathworks.com/matlabcentral/fileexchange/49985-pcolor3), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!


Version Published Release Notes

Added features for alpha scaling and direct (no interpolation) plotting.