Basic question about coloring of a 3d plot

조회 수: 1 (최근 30일)
Marc
Marc 2013년 7월 5일
Hi,
I have the following question:
I have a 3D plot which shows the dependencies of 3 variables. One of these variables is the wavelength of light. Is it possible to have one specified color for each wavelength along the wavelength axis of my plot?
For example: if the wavelength equals 530 nm, then I would want the plot to be green for all points where wavelength = 530nm.
I am looking forward to, and appreciate your answers!
Kind regards, Marc

답변 (2개)

Kelly Kearney
Kelly Kearney 2013년 7월 5일
Some more details about your plot would help... are you plotting points? Lines? Surfaces? A scatter plot could help with points; a patch with facecolor and/or edgecolor set to interp could help with lines or surfaces.
  댓글 수: 2
Kelly Kearney
Kelly Kearney 2013년 7월 5일
It would be helpful if you could comment on a specific answer rather than adding a new answer yourself. But in response to your clarification...
The fourth input to mesh specifies the color to plot the surface. For example, the following colors the mesh according to the x-coordinate, which I'm assuming represents wavelength:
z = peaks;
[x,y] = meshgrid(linspace(400,750,49), 1:49);
mesh(x,y,z,x);
colorbar;
Getting your colormap to reflect the visible spectrum is a little trickier using Matlab's native colormaps. Using one of my own functions (available here) along with this color palette table will accomplish it pretty easily though:
cptcmap('visspec', 'mapping', 'direct');
Marc
Marc 2013년 7월 5일
Hi Kelly,
I am sorry for having posted an answer and not commented on yours. I am new to this forum and did not know about the difference between the two. In the future, I will use the commenting and answer options accordingly.
I tried what you posted, setting the wavelength axis as the fourth input to mesh, but I am only getting a "red" plot.
I will read through the links you provided and try with that information - thank you very much!
If I don't get it to work, I'll let you know and ask for more specific help.
Marc

댓글을 달려면 로그인하십시오.


Marc
Marc 2013년 7월 5일
Hi Kelly,
I am using mesh(x,y,z), if that is what you mean.
Marc

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by