Apply a color map to a 2d line

조회 수: 40 (최근 30일)
Nigel Davis
Nigel Davis 2022년 5월 17일
댓글: Nigel Davis 2022년 5월 17일
Hi
My code outputs a line graph from an array as seen below.
I need to apply a simple colourmap, say from blue to green for example, to this line from another set of values.
I think I can create the required colourmap but I don't know how to apply it to the line!
Any assistance would be greatly appriciated.
Thanks.
line(lans(1,:),1:61,'LineWidth',10)

채택된 답변

KSSV
KSSV 2022년 5월 17일
Read about patch
x = linspace(1,10,15);
y = sin(x);
y(end) = NaN;
c = y;
figure
patch(x,y,c,'EdgeColor','interp');
colorbar;
  댓글 수: 1
Nigel Davis
Nigel Davis 2022년 5월 17일
Wow thats looks like what I'm after.
I really appreciate the help, thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by