How to set zero value boxes transparent in 3D plots?

Click For Summary
SUMMARY

This discussion focuses on making zero-value boxes transparent in 3D plots using MATLAB's ind2patch function. The user employs a matrix M to represent values in a 3D space and seeks to display only non-zero values. The solution involves adjusting the FaceAlpha property in the patch function to achieve transparency for zero-value boxes. An example provided by the function's author illustrates this implementation effectively.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of 3D plotting concepts
  • Knowledge of matrix manipulation in MATLAB
  • Experience with the patch function in MATLAB
NEXT STEPS
  • Review the documentation for ind2patch in MATLAB
  • Explore the patch function and its properties in MATLAB
  • Learn about customizing 3D plots in MATLAB
  • Investigate techniques for visualizing sparse data in 3D
USEFUL FOR

Data scientists, MATLAB users, and anyone involved in 3D data visualization who needs to optimize the display of sparse datasets.

kelvin490
Gold Member
Messages
227
Reaction score
3
I used a function called ind2patch to make a big 3D block which contains a number of smaller blocks in 3 dimensions. Each small block has a value which the magnitude is represented by a color.One example is shown below:
DisDen.png

However, most of the boxes have very low or zero value and I don't need to show them. How can I make these boxes transparent? I just want to show the boxes with non-zero value.

For the above 3D plot I use a matrix M to store the value of each box (i,j,k) and use the following algorithm to plot:

indPatch=1:numel(M);
[F,V,C]=ind2patch(indPatch,M,'v'); %Call the function ind2patch in order to plot 3D cube with color

xlabel('y','fontsize',20);ylabel('x','fontsize',20); zlabel('z','fontsize',20); hold on;
set(get(gca,'xlabel'),'Position',[5 -50 30]); %set position of axis label
set(get(gca,'ylabel'),'Position',[5 50 -15]);
set(get(gca,'zlabel'),'Position',[64 190 -60]);
patch('Faces',F,'Vertices',V,'FaceColor','flat','CData',C,'EdgeColor','k','FaceAlpha',0.5);
axis equal; view(3); axis tight; axis vis3d; grid off;
 
Physics news on Phys.org
The person who wrote that function provided an example where he does what you are asking. Did you look at his example?
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
5
Views
8K