필터 지우기
필터 지우기

How to specify the RGB color of each line in a waterfall plot?

조회 수: 7 (최근 30일)
KAE
KAE 2017년 2월 21일
편집: KAE 2018년 10월 9일
Is there a way to specify the RGB color of each line in a waterfall plot? It seems like I can't set the 15 individual lines' edge color to the corresponding rgbDesired values in the w1 patch example below. I could plot each 'line' as a separate vertical patch and set its edge color individually, but is there a better way?
figure;
[X,Y,Z] = peaks(50);
% Make different x,y dimensions to make it easier to understand
ix = 1:15; % Will produce 15 lines
iy = 1:20;
X = X(ix, iy); Y = Y(ix, iy); Z = Z(ix, iy);
w1 = waterfall(X,Y,Z); % Waterfall with color set by peak height
% Alternative RGB values we seek to use for each line
rgbDesired = rand(length(ix), 3);
w1 =
Patch with properties:
FaceColor: [1 1 1]
FaceAlpha: 1
EdgeColor: 'flat'
LineStyle: '-'
Faces: [15×25 double]
Vertices: [375×3 double]

채택된 답변

Adam
Adam 2017년 2월 21일
I'm not really familiar with waterfall plots, but when I run your code there are 15 lines and the CData is also 15x25 so I'm not sure where 20 colours would fit exactly.
You can edit the whole CData at once, e.g.
w1.CData = rand( 25, 15, 3 );
but it has to be the expected size.
  댓글 수: 1
KAE
KAE 2017년 2월 21일
편집: KAE 2018년 10월 9일
What I am trying to do is to make each of the 15 lines have a solid color that I specify. So I altered your answer code as follows, and it works great,
% Expand desired RGB line colors from dimensions 15x3 to 25x15x3
rgbDesiredBigger = repmat(reshape(rgbDesired, [1 15 3]), [25 1 1]);
w1.CData = rgbDesiredBigger;

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by