I have to plot 20 curves . I have stored the data in matrix. I want to color the plot from light blue to dark blue.Please suggest me code

 채택된 답변

Adam Danz
Adam Danz 2021년 3월 23일
편집: Adam Danz 2023년 3월 17일

0 개 추천

Update
As of MATLAB R2023a you can use the colormap sky
cmap = sky(256);
x = linspace(0,.5*pi,500)';
plot(sin(x).*linspace(0,1,20))
colororder(sky(20))
Prior to R2023a
Here's the colormap used by heatmap that spans from light to dark blue
n=256;
cmap = [linspace(.9,0,n)', linspace(.9447,.447,n)', linspace(.9741,.741,n)'];

댓글 수: 2

Bhawna Malik
Bhawna Malik 2021년 3월 23일
whqat is n?
Jan
Jan 2021년 3월 23일
n is the number of colors.

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

추가 답변 (2개)

Jan
Jan 2021년 3월 22일
편집: Jan 2021년 3월 22일

2 개 추천

x = rand(10, 20) + (1:10).';
figure;
axes('NextPlot', 'add');
color1 = [0.5, 0.5, 1]; % Set colors according to your definition of
color2 = [0, 0, 0.5]; % "light blue" and "dark blue"
m = linspace(0, 1, 10);
for k = 1:10
color = color1 * m(k) + color2 * (1 - m(k));
plot(x(k, :), 'Color', color);
end
Image Analyst
Image Analyst 2021년 3월 22일

1 개 추천

See my colororder demo. Adapt as needed. The demo lets you pick any built-in colormap, but of course you could use your own if you want.

카테고리

도움말 센터File Exchange에서 Color and Styling에 대해 자세히 알아보기

질문:

2021년 3월 22일

편집:

2023년 3월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by