Add new headers.
[scilab.git] / scilab / modules / graphics / macros / graypolarplot.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) INRIA
3 // This file must be used under the terms of the CeCILL.
4 // This source file is licensed as described in the file COPYING, which
5 // you should have received as part of this distribution.  The terms
6 // are also available at    
7 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
8
9
10 function graypolarplot(theta,rho,z,varargin)
11 [lhs,rhs]=argn(0)
12 if rhs<=0 then
13   rho=1:0.2:4;theta=(0:0.02:1)*2*%pi;
14   z=30+round(theta'*(1+rho^2));
15   xbasc();
16   f=gcf();
17   f.color_map=hotcolormap(128);
18   f.background= 128;
19   f.foreground=1;
20   a=gca();
21   a.background= 128;
22   a.foreground=1;
23   graypolarplot(theta,rho,z)
24   return
25 end
26
27
28 R=max(rho)
29 nv=size(varargin)
30 if nv>=1 then strf=varargin(2),else  strf='030',end
31 if nv>=2 then rect=varargin(4),else  rect=[-R -R R R]*1.1,end
32 drawlater()
33 plot2d(0,0,1,strf,' ',rect)
34
35 [rho,k]=sort(rho);z=z(:,k);
36
37 nt=size(theta,'*');theta=matrix(theta,1,-1)*180/%pi
38 for k=1:size(rho,'*')-1
39   r=rho(k)
40   xfarcs([-r*ones(1,nt-1);
41            r*ones(1,nt-1)
42            2*r*ones(1,nt-1)
43            2*r*ones(1,nt-1)
44            theta(1:$-1)*64;
45            (theta(2:$)-theta(1:$-1))*64
46            ],(z(1:$-1,k)+z(2:$,k)+z(1:$-1,k+1)+z(2:$,k+1))/4)
47 end
48 r=rho($)
49 if r<>0 then
50   xfarcs([-r;r;2*r;2*r;0;360*64],xget('background'))
51 end
52
53 step=R/5
54 r=step;dr=0.02*r;
55 for k=1:4
56   xset("dashes",3)
57   xarc(-r,r,2*r,2*r,0,360*64)
58   xset("dashes",1)
59   xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12),string(round(10*r)/10))
60   r=r+step
61 end
62 xset("dashes",1)
63 xarc(-r,r,2*r,2*r,0,360*64)
64 xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12),string(round(10*r)/10))
65
66 rect=xstringl(0,0,'360');w=rect(3);h=rect(4);d=sqrt(w^2+h^2)/1.8
67 r=R+d
68 for k=0:11
69   xset("dashes",3)
70   xsegs([0;R*cos(k*(%pi/6))],[0;R*sin(k*(%pi/6))])
71   xset("dashes",1)
72   xstring(r*cos(k*(%pi/6))-w/2,r*sin(k*(%pi/6))-h/2,string(k*30))
73 end
74 xset("dashes",1)
75 drawnow()
76
77 endfunction