MATLAB Answers

How I can change the color range of surface plot

46 ビュー (過去 30 日間)
GreenPiece
GreenPiece 2017 年 12 月 29 日
コメント済み: KSSV 2017 年 12 月 29 日
Hi everyone, I followed the answer of this question: https://ch.mathworks.com/matlabcentral/answers/5042-how-do-i-vary-color-along-a-2d-line I would like to change the range of the color in a specific range. I change the code as below but it did not work. Please suggest me a solution. Thanks!
x = 0:.05:2*pi;
y = sin(x);
z = zeros(size(x));
col = linspace(0, 255, size(x,2)); % This is the color, vary with x in this case.
% colormap([col; col; col].')
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);

  0 件のコメント

サインイン to comment.

回答 (1 件)

KSSV
KSSV 2017 年 12 月 29 日
doc caxis

  4 件のコメント

表示 1 件の古いコメント
KSSV
KSSV 2017 年 12 月 29 日
col = linspace(0, 126, size(x,2)); % This is the color, vary with x in this case.
won't this work?
GreenPiece
GreenPiece 2017 年 12 月 29 日
It is not full range color RGB, there is no red color in the result. That why I want to modify the command to get the full range of colors.
KSSV
KSSV 2017 年 12 月 29 日
Ok....do interpolation of size 255 to 126.

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by