Displaying 3D data with adjusted transparency values in Matlab

8 次查看(过去 30 天)
I have a 3D matrix of size 300x178x124 that I plot using the slice command:
diff = double(squeeze(glacier));
diff(diff==0)=nan;
h = slice(realx,realy,realz,diff, [], [], 1:size(diff,1));
set(h, 'EdgeColor','none', 'FaceColor','interp', 'FaceLighting','gouraud')
colormap(flipud(pink))
colorbar;
caxis([0 5])
shading interp
daspect([0.5 1 .2])
view(-149,32)
I was wondering if it is possible to
(a) add transparency based upon the value of the 3D matrix, e.g. value of 0 in "diff" is 100% transparency while the maximum value of "diff" is displayed using 0% transparency.
(b) is there a way to visually improve the 3D presentation? It seems to me that the data display is rather patchy and does not really look that nice.

回答(1 个)

Shubham
Shubham 2023-9-28
I understand that you want to add transparency to the plot based on the values of diff. You can modify the alpha values of the surface using FaceAlpha property. Normalize the values in the diff matrix and use them in place of alpha values as the values should be between 0 and 1.
You can refer to the following:
For improving the 3D representation, you can adjust the colormap.  Instead of using the flipud(pink) colormap, you can experiment with different colormaps that better represent your data. MATLAB provides several built-in colormaps, or you can create your own custom colormap.
Hope this helps!!

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by