在Matlab中绘制三角矩阵的网格

发布于 2024-12-23 02:42:37 字数 289 浏览 3 评论 0原文

我一直试图弄清楚如何从 Matlab 的 3d 图中“隐藏”三角矩阵的无用部分。

我尝试在图表的该部分上方绘制一个网格

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

,但没有帮助。我该怎么做呢?

半工作的唯一方法是使用色标,但它并没有完全起作用,加上我需要黑白 eps,即使它原本看起来是白色的,它也会将颜色显示为黑色......

这是我的最后的希望;) 芭芭拉

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥抱影子 2024-12-30 02:42:37

简短回答:将“无用”数据替换为 nan 值,因为 MATLAB 不会绘制 nan 数据值。

将 nan 值插入矩阵的另一半应该可以解决问题。请参阅下面的示例 - 它很笨重,但应该给出想法。我选择乘以 nan,如图所示,但我想到了其他六件事。

% 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')

显示和隐藏对角矩阵“无用”部分的图

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文