필터 지우기
필터 지우기

How to plot single colorful line?

조회 수: 2 (최근 30일)
Zack Trahem
Zack Trahem 2023년 6월 20일
댓글: Zack Trahem 2023년 6월 20일
Iam trying to plot a single line graph varaying colororder depending on the intensity increse.
x=[1 2 3 4 5 6 ];
y=[1 2 3 4 5 6 ];
plot(x,y), colororder(jet)
expecting to color change over line. Thank you.

채택된 답변

KSSV
KSSV 2023년 6월 20일
x=[1 2 3 4 5 6 ];
y=[1 2 3 4 5 6 ];
z = zeros(size(x));
col = x; % This is the color, vary with x in this case.
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);
  댓글 수: 1
Zack Trahem
Zack Trahem 2023년 6월 20일
Thank you so much, this is what i was looking for.

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

추가 답변 (1개)

DGM
DGM 2023년 6월 20일
편집: DGM 2023년 6월 20일
This can't be done with a single line object. It can be done with multiple line objects or with patch objects. This thread has examples of both.

카테고리

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