Octave Plot 使用说明

使用plot绘图
X为数据矩阵,每一列为一个特征。
现在为 m×2 的矩阵,即两维特征。
y为数据结果向量,为 m×1 向量,y中要么1,要么0.

则绘制图如下:

pos = find(y==1);neg = find(y==0);
plot(X(pos,1),X(pos,2),'k+','LineWidth',2,'MarkerSize',7);
plot(X(neg,1),X(neg,2),'ko','MarkerFaceColor','r','MarkerSize',7);

pos为向量中为1的行序号组成的向量,neg为向量中为0的行序号组成的向量
效果如下:
Octave Plot 使用说明_第1张图片


 Format arguments:
    linestyle
          '-'  Use solid lines (default).
          '--' Use dashed lines.`
          ':'  Use dotted lines.
          '-.' Use dash-dotted lines.
    markerstyle
          '+'  crosshair
          'o'  circle
          '*'  star
          '.'  point
          'x'  cross
          's'  square
          'd'  diamond
          '^'  upward-facing triangle
          'v'  downward-facing triangle
          '>'  right-facing triangle
          '<'  left-facing triangle
          'p'  pentagram
          'h'  hexagram
    color
          'k'  blacK
          'r'  Red
          'g'  Green
          'b'  Blue
          'm'  Magenta
          'c'  Cyan
          'w'  White 
Useful properties to modify are "linestyle",
     "linewidth", "color", "marker", "markersize", "markeredgecolor",
     "markerfacecolor".

你可能感兴趣的:(Octave)