How to Specify Colors, Line Styles, and Marker Types in MATLAB Graphs
Properties
The properties of a graph can be specified as follows.
Graph Color | Marker | Line Style |
---|---|---|
Red r | Dot . | Solid - |
Green g | Star * | Dotted : |
Blue b | X x | Dash-dot -. |
Black k | Circle o (letter o) | Dashed -- |
Yellow y | Plus + | |
Magenta m | Square s | |
White w | Diamond d | |
Cyan c | Star p | |
Triangle down v | ||
Triangle up ^ | ||
Triangle left < | ||
Triangle right > | ||
Hexagon h |
Example
x=linspace(0,1,20);
y=x.^3+3.*x.^2+3.*x+1;
figure()
plot(x,y,'ro')
hold on
plot(x,y+1,'g-')
plot(x,y+2,'c:')
plot(x,y+3,'k--')
legend({'ro', 'g-', 'c:', 'k--'})