How to make three-dimensional graph with a three-dimensional matrix?

2 ビュー (過去 30 日間)
JeongWon Kim
JeongWon Kim 2022 年 10 月 26 日
回答済み: Taru 2022 年 11 月 22 日
I want to make the three-dimensional graph matrix coordinates the same as the graph coordinates.
And I hope the value of the matrix will be color.
so its my code
-------------------------------------------------------------------
A0=[1 1 ; 1 1]
A1=[2 2 ; 2 2]
A2=[4 4 ; 4 4]
C = cat(3,A0,A1,A2);
x=[0:2:2];
y=[0:2:2];
z=[0:2:4];
[X,Y,Z]=meshgrid(x,y,z);
h = slice(X, Y, Z, C,x, y, z);
set(h,'EdgeColor','none',...
'FaceColor','interp',...
'FaceAlpha','interp');
alpha('color');
colormap(jet);
-------------------------------------------------------------------
It usually works well, but if one value is too large, the rest of the values are hard to see.
for example A0=[100 1 ; 1 1 ]
how can i fix this problem?
  2 件のコメント
Jan
Jan 2022 年 10 月 26 日
A simplified version to demonstrate the problem:
A0 = [1 1 ; 1 1];
A1 = [2 2 ; 2 2];
A2 = [4 4 ; 4 4];
C = cat(3,A0,A1,A2);
x = 0:2:2; % No need to contactenate 0:2:2 with nothing
y = 0:2:2;
z = 0:2:4;
figure;
h = slice(x,y,z, C,x, y, z); % No need for MESHGRID
set(h,'EdgeColor','none','FaceColor','interp','FaceAlpha','interp');
alpha('color');
colormap(jet);
figure
A0 = [100 1 ; 1 1];
C = cat(3,A0,A1,A2);
h = slice(x,y,z, C,x, y, z); % No need for MESHGRID
set(h,'EdgeColor','none', 'FaceColor','interp','FaceAlpha','interp');
alpha('color');
colormap(jet);
I cannot guess, what the last image should show. What should be visible? "rest of the values are hard to see" is not clear enough.
Bjorn Gustavsson
Bjorn Gustavsson 2022 年 10 月 26 日
If you have such order-of-magnitude differences between values one type of thing to do is to display the log of the values, this is typical for any type of line-plots (for that case we even have the semilogx, semilogy, and loglog functions) or for pseudo-color or surface-plots (for example gain and directivity of antenna-patterns are rarely seen on a linear scale), the same should hold for these types of volumetric plots. If you want some other transform like for example sqrt instead of a log, that would work as fine, but would be less standard. For only 8 data-points you might also consider a dumbed-down version of this display and go with scatter3 instead.
Also we should remember that our visual-cognitive system are not evolved to interpret volume-renderings like these. Proper quantitative interpretation of these are equivalent to the 3-D tomography problem and the mathematical necessary requirement for solving those are that one have at least one eye (technically cone-beam projection) on every plane that cuts through the support of the function. Since we are stuck with 2 eyes, at least for now, we cannot achive this.

サインインしてコメントする。

採用された回答

Taru
Taru 2022 年 11 月 22 日
Hi,
I understand that you want the colormap to depict the values in the matrix distinctively even if there is a sharp difference among those values.
This can be achieved if you can scale down the values using 'log', 'sqrt', etc.
A0 = sqrt(log([1 1 ; 1 1]));
A1 = sqrt(log([2 2 ; 2 2]));
A2 = sqrt(log([4 4 ; 4 4]));
C = cat(3,A0,A1,A2);
x = 0:2:2;
y = 0:2:2;
z = 0:2:4;
figure;
h = slice(x,y,z, C,x, y, z);
set(h,'EdgeColor','none','FaceColor','interp','FaceAlpha','interp');
alpha('color');
colormap(jet);
A0 = sqrt(log([100 1 ; 1 1]));
A1 = sqrt(log([2 2 ; 2 2]));
A2 = sqrt(log([4 4 ; 4 4]));
C = cat(3,A0,A1,A2);
x = 0:2:2;
y = 0:2:2;
z = 0:2:4;
figure;
h = slice(x,y,z, C,x, y, z);
set(h,'EdgeColor','none','FaceColor','interp','FaceAlpha','interp');
alpha('color');
colormap(jet);
Above is an example for the scaling and the resultant graphs. The scaling operations can be coupled further with more operations to scale down the difference between the maximum and minimum values.
Lim=clim
Above code will reveal the minimum and maximum values which can be manipulated to have a smaller difference as compared to the original unscaled data.
Hope it serves your purpose.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeBiomedical Imaging についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by