1
votes

I have been trying to figure out how to "hide" the useless part of the triangular matrix from my 3d plot in Matlab.

I have tried drawing a mesh just above that part of the graph with

'EdgeAlpha', 1, 'FaceAlpha', 1,'FaceColor','w','EdgeColor','none'

but it does not help. How should I do it instead?

The only method the semi-worked is using the color scale, but it did not work all the way, plus I need the black and white eps's, which will show the color as black even if it looks white originally...

This is my last hope ;) Barbara

1
You haven't really given us enough information to help you. What code are you currently using to plot your matrix? Do you have a sample image of what the result should look like?gnovice
After struggling with the issue for more than three weeks, I have now figured it out myself. If you assign NaN value to the unwanted parts of the matrix, it will not show on the graph! I wish this easy solution was documented by MATLAB people or possible to find online...BBB

1 Answers

1
votes

Short answer: replace "useless" data with the value nan because MATLAB does not plot data values that are nan.

Inserting nan values into the other half of the matrix should do the trick. See the example below - it's clunky, but should give the idea. I chose to multiply by nan, which I attained as shown, but there are half a dozen other things that came to mind.

% Create random data for illustration
data = tril(rand(50));

% I chose to divide by a lower triangular ones matrix (zeros above the
% diagonal) to get nan above the diagonal and ones below
nan_above_diag_ones_below = 1./tril(ones(50,50)); 

% Plot data with and without hiding the "useless part"
figure, 
subplot(1,2,1), mesh(data), title('"useless" part shown')
subplot(1,2,2), mesh(data.*nan_above_diag_ones_below), 
title('"useless" part hidden')

Plots showing "useless" part of diagonal matrix shown and hidden