Plot a 3D array using patch
Plot a 3D array using patch
===========================
Adam H. Aitkenhead
adam.aitkenhead@christie.nhs.uk
The Christie NHS Foundation Trust
17th August 2010
USAGE
=====
This function enables a 3D array to be displayed using a patch surface mesh. To plot a 3D logical array, the function is called using the following syntax:
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ);
Alternatively, a 3D numeric array can be plotted such that the colour of each facet corresponds to the value of each voxel in the array. The plot is generated using the following command. (Note that voxels which are not to be displayed should contain a value of NaN.)
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ,'col');
The colormap to be used for the display of a 3D numeric array can be defined as follows:
>> cmap = jet(16);
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ,cmap,'col');
Also, the colorbar lower and upper limits can be defined by the user as follows:
>> clim = [1,10];
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ,clim,'col');
INPUT PARAMETERS
================
gridINPUT - 3D array of size (P,Q,R) - If not using the flag 'col', then gridINPUT should be a logical array. If using the flag 'col', then gridINPUT should be a numeric array, and all voxels which are not to be displayed should contain a value of NaN.
gridX (optional) - A 1xP array - List of the X axis coordinates.
gridY (optional) - A 1xQ array - List of the Y axis coordinates.
gridZ (optional) - A 1xR array - List of the Z axis coordinates.
cmap (optional) - A Nx3 array - The colormap definition. When plotting using the 'col' flag, cmap must be an Nx3 array, eg jet(32). When plotting a logical array, cmap must be an RGB triplet, eg [0.5,0.5,0].
clim (optional) - A 2x1 array - The colormap upper and lower limits.
ADDITIONAL INPUT FLAGS
======================
'col' (optional) - When this flag is present, the surface is plotted using colours which correspond to the value in each voxel. In the input array gridINPUT, voxels which are not to be displayed should have a value of NaN.
'barN' (optional) - Display a colorbar on North of plot.
'barE' (optional) - Display a colorbar on East of plot.
'barS' (optional) - Display a colorbar on South of plot.
'barW' (optional) - Display a colorbar on West of plot.
OUTPUT PARAMETERS
================
hpat (optional) - Handle to the patch object.
hcbar (optional) - Handle to the colorbar.
EXAMPLE
=======
For two examples, run the following code:
>> load exampleA.mat
>> figure
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ);
>> load exampleB.mat
>> figure
>> cmap = jet(16);
>> hpat = PATCH_3Darray(gridINPUT,gridX,gridY,gridZ,'col',cmap);
Citar como
Adam A (2024). Plot a 3D array using patch (https://www.mathworks.com/matlabcentral/fileexchange/28497-plot-a-3d-array-using-patch), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
Etiquetas
Agradecimientos
Inspiración para: Spectral Imaging Toolbox, 2d and 3d brain plots
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
PATCH_3Darray/
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.11.0.0 | The user can now define the lower and upper limits of the colorbar using the input parameter 'clim'. Also, the input flag 'sym' has been removed as this can be done using clim instead. |
||
1.9.0.0 | Provide the handle to the colorbar as an optional output. |
||
1.8.0.0 | Some minor code optimisations |
||
1.7.0.0 | Bugfix: Prevent a hole from appearing at the lowest values in a full colour plot. |
||
1.5.0.0 | The user can now specify the colour map for the display of a 3D numeric array. |
||
1.4.0.0 | Minor bugfix |
||
1.3.0.0 | Now enables a 3D numeric array to be plotted such that each facet corresponds to the value of each voxel in the array. |
||
1.2.0.0 | Added missing example.mat file |
||
1.1.0.0 | Improved documentation |
||
1.0.0.0 |