Octave graphic add-on, Octplot



česky

1.2 Basic graphs I - plot



Function file: h = plot (x,y,FMT)


This function plots classic 2D graph defined by points in coordinates x and y. It returns handle to variable h.


Combinations of parameters x and y can be this:
  • parameter x don't set (plot(y)) - x values is added automatic, first value is 1, next 2,3 ...

  • x scalar, y scalar - it draws one point in coordinate x,y

  • x vector, y vector - it drwas one graph defined by points in coordinates x,y; x and y must be the same length

  • x matrix (mxr), y matrix (nxs) - it draws r (s) graphs, individual points are taken from columns matrix x and y; matrix and y must have the same number of rows.

    x=[-2.1 -2.1;-0.8 0.6;1.4 1.7;2.5 2.8;3.9 3.4;4.8 4.8];
    y=[0.8 1.6;4.1 2.8;1.2 3.8;-1.2 1.4;4.3 2.1;4 1.5];
    plot(x,y)


  • x vector, y matrix - it draws n graphs (n - number of rows matrix y), x values are for all graphs the same; length (number of points) of vector x must be equal number of columns matrix y.

    x=[-2.1 -1.3 0.5 1.4 2.8 3.4];
    y=[1 5 4.1 2 4.3 2.1;2 1.8 5.3 -0.8 2.3 4.1];
    plot(x,y)


  • x matice, y vektor - it draws m graphs (m - number of rows matrix x), y values are for all graphs the same; length (number of points) of vector x must be equal number of columns matrix x.

    x=[-2.1 -1.3 0.8 1.6 2.4 3.7;-3.5 -1.8 0.9 2.4 3.8 4.2];
    y=[0.8 1.6 4.1 2.8 1.2 3.8];
    plot(x,y)


Possibilities of optional parameter FMT:

entry describe of parameter
'-' styl - line (default)
':' styl - dotted line
'--' styl - dash line
'-.' styl - dot and dash line
';text;' title of line
'c' color - 'r','g','b','c','m','y','k','w'
's' form of point - '+', 'o', '*', '.', 'x', '^', 'v', '>', '<', 's', 'd'


Examples:
x=[-2.1 -1.3 0.5 1.4 2.8 3.4];
y=[1 5 4.1 2 4.3 2.1];
plot(x,y,"b^:;cara;")




Two lines various format (or more):
x1=[-1.5 -0.8 0.9 1.7];
y1=[2.1 -0.8 3.1 3];
x2=[-1.5 0.4 1.1 1.7];
y2=[-1.4 2.3 2.4 0.7];
plot(x1,y1,"m--+;carkovana;",x2,y2,"g:d;teckovana;");





<<< 1.1 Function for operations with figure 1.3 Basic graphs II - area, line, stem >>>

© 2008 David Prokop