plot with light to dark blue colour
95 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Adam Danz
on 23 Mar 2021
Edited: Adam Danz
on 17 Mar 2023
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 Comments
More Answers (2)
Jan
on 22 Mar 2021
Edited: Jan
on 22 Mar 2021
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
0 Comments
Image Analyst
on 22 Mar 2021
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/558772/image.png)
0 Comments
See Also
Categories
Find more on Colormaps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!