rename graphics2 --> graphics
[scilab.git] / scilab / modules / graphics / macros / fplot2d.sci
1 function []=fplot2d(xr,f,style,strf,leg,rect,nax,void)
2         // 2D plot of function f : a Scilab function or the name (as a string)
3         //  of a dynamically linked function.
4         // Enter fplot2d() for an example.
5         // deff('<y>=f(x)','y=sin(x)+cos(x)');
6         // fplot2d(f,0:0.1:%pi);
7         //!
8         // Copyright INRIA
9         
10         [lhs,rhs]=argn(0)
11         if rhs <= 0 then   // demo
12                 
13                 title_demo = [
14                         '';
15                         'Demo of fplot2d()';
16                         '========================================';
17                         ''];
18                 
19                 s_mat=[
20                         'deff(''[y]=f(x)'',''y=sin(x)+cos(x)'');';
21                         'fplot2d(0:0.1:%pi,f);'];
22                 
23                 write(%io(2),title_demo);
24                 write(%io(2),s_mat);
25                 write(%io(2),' ');
26                 execstr(s_mat);
27                 return
28         end
29         
30         if type(xr)=='10' then // logflag passed first
31                 error('First argument must be the discretization of x')
32         elseif rhs < 2 then 
33                 error('at least 2 input arguments required')
34         end
35         //handling optionnal arguments
36         
37         opts=[]
38         
39         if exists('style','local')==1 then opts=[opts,'style=style'],end
40         if exists('strf','local')==1 then opts=[opts,'strf=strf'],end
41         if exists('leg','local')==1 then opts=[opts,'leg=leg'],end
42         if exists('rect','local')==1 then opts=[opts,'rect=rect'],end
43         if exists('nax','local')==1 then opts=[opts,'nax=nax'],end
44         if exists('logflag','local')==1 then opts=[opts,'logflag=logflag'],end
45         if exists('frameflag','local')==1 then opts=[opts,'frameflag=frameflag'],end
46         if exists('axesflag','local')==1 then opts=[opts,'axesflag=axesflag'],end
47         if size(opts,2)<rhs-2 then  error('invalid named arguments'),end
48         
49         execstr('plot2d(xr,feval(xr,f),'+strcat(opts,',')+')')
50         
51 endfunction