How to change color of vectors when plot a matrix?

6 views (last 30 days)
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
Image Analyst on 27 Sep 2015
See my colororder demo, attached. You can make the lines be any color you want by changing the "ColorOrder".

Star Strider
Star Strider on 27 Sep 2015
See the documentation for plot, specifically Specify Line Style, Color, and Marker.
  2 Comments
my
my on 27 Sep 2015
It only works to change the color for the entire matrix. I need to change color for each vector in Y (say Y is a N*3 matrix). Any ideas?

Sign in to comment.


Stephen23
Stephen23 on 27 Sep 2015
Edited: Stephen23 on 27 Sep 2015
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 Line Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!