MESHZ - Change Curtain color.
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm making a plot of a terrian using:
g=meshz(XI, YI, ZI);
demcmap(ZI); %Set terrain color
set(g,'FaceColor','interp','EdgeColor','k');
It's posible to change the curtain color without affect the terrian color?
Thanks, Cristian
0 个评论
采纳的回答
Patrick Kalita
2011-9-15
Yes, it is possible. You can do it by adjusting the CData property of the surface that meshz creates. meshz will create a surface whose CData matrix is just the height values of the surface padded with two extra rows/columns on each side to make the curtain. If you want to change the color of the curtain, you can generate your own CData array. For example:
% Make the initial plot
[x, y, z] = peaks;
g = meshz(x, y, z);
set(g,'FaceColor','interp','EdgeColor','k');
% Generate a new CData matrix by
% allocating a new array that has two extra rows/columns on each
% side. Note that the x, y, and z arrays in this example are 49x49
% Therefore we need C to be 53x53 (53 = 49 + 2 + 2). Obviously this
% could be automated using the SIZE function. The -4 here means that
% the curtain will be colored with whatever color represents -4 in
% the colormap ... you could change this to be whatever works for your
% application.
C = -4 * ones( 53, 53 );
% Insert the Z-data into the matrix.
C(3:51, 3:51) = z;
% Set the property on the surface.
set(g, 'CData', C)
colorbar;
2 个评论
Patrick Kalita
2011-9-16
Sure, one thing you could try is adding that color to the bottom of the colormap:
newColormap = [0 0 0; get(gcf, 'Colormap')]
set(gcf, 'Colormap', newColormap);
Then instead of -4 choose a value that is at least as small as any of the other values in the CData array ( e.g. min(ZI(:)) )... or -Inf, that will always use the bottom color of the colormap.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Blue 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!