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

7 次查看(过去 30 天)
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