MESHZ - Change Curtain color.

조회 수: 1 (최근 30일)
Cristian D
Cristian D 2011년 9월 12일
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

채택된 답변

Patrick Kalita
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
Cristian D
Cristian D 2011년 9월 15일
Thank you Patrick,
I will try it this weekend!. It's posible to change the current map color in order to an specific value take an specific color? For example: turn -4 value to black without change the rest of the colormap.
Regards,
Cristian
Patrick Kalita
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 CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by