How to change color of vectors when plot a matrix?
Show older comments
I have plot(Y) where Y is a matrix
How do I change resulted color and line pattern for each vector inside Y? Many thanks!
Answers (3)
Image Analyst
on 27 Sep 2015
2 votes
See my colororder demo, attached. You can make the lines be any color you want by changing the "ColorOrder".
Set the axes colororder property (here the colormap is winter, but you can choose the colormap to suit):
N = 6;
axes('ColorOrder',winter(N),'NextPlot','replacechildren')
X = linspace(0,pi*3,1000);
Y = bsxfun(@(x,n)n*sin(x+2*n*pi/N), X.', 1:N);
plot(Y)

Categories
Find more on Color and Styling 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!