Basic question about coloring of a 3d plot
显示 更早的评论
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
2013-7-5
0 个投票
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
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
2013-7-5
类别
在 帮助中心 和 File Exchange 中查找有关 Color and Styling 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!