Using colormap to graph function of three variables

조회 수: 36 (최근 30일)
JDub
JDub 2023년 3월 5일
편집: DGM 2023년 3월 6일
I have a function of three variables, f(x,y,z), represented by an Nx4 matrix, where columns 1, 2, and 3 are the x, y, and z values respectively and column 4 is the dependent variable. Is it possible to use a colormap to represent this function, where the x, y, and z values are the positions on the x, y, and z axes respectively and the dependent variable is represented exclusively by the color spectrum? I am aware that the colormap command is typically used for functions of two variables, combining the z position and color spectrum into a single variable, but I would like them to be separate.
I am relatively new to matlab, so apologies if this is a naive question. If further detail is necessary, I can elaborate.

답변 (2개)

John D'Errico
John D'Errico 2023년 3월 5일
Could you? I suppose, in theory, you could. But it would not make a lot of sense. The problem is, suppose you have all different colors, so all different values of the 4th variable. Now, you want to plot them. But in order to see what lies near the back of your object, you will need to look through those different colors to see that. And the only way you can do that is for the colors in front to be translucent. But even so, suppose the color in back from your colormap happens to be white, but in front, you have some values that would force you to essentially look through a yellow filter, because in front of that white region, you have a color that is yellow from the colormap? The image you would generate would be terribly confusing.
Worse, it would be my expectation that anything in back would be rendered virtually impossible to visualize what colors they were, because of the colors in front of them filtering the scene. As such, your request makes little sense. Sorry. But you need to think it through to see how it would work, or more accurately, not work.
Yes, you can use tools like an iso-surface, probably your best choice. But that will show you the level surface of only one value of the 4th variable.

DGM
DGM 2023년 3월 6일
편집: DGM 2023년 3월 6일
Depending on what things look like, you might be able to get away with a colormapped scatter plot. That said, I think it's difficult to read, especially in a static view.
x = randn(100,1);
y = randn(100,1);
z = randn(100,1);
c = (x+y+z)/3; % some function of position
scatter3(x,y,z,20,c,'filled');
Otherwise your options are limited. Slicing and isosurfaces have already been mentioned.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by