MESHZ - Change Curtain color.
조회 수: 1 (최근 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에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!