Scilab Reorganisation. Add macros in the graphics module.
[scilab.git] / scilab / modules / graphics / macros / graypolarplot.sci
1 function graypolarplot(theta,rho,z,varargin)
2 [lhs,rhs]=argn(0)
3 fstyle=get('figure_style')
4 if rhs<=0 then
5   rho=1:0.2:4;theta=(0:0.02:1)*2*%pi;
6   z=30+round(theta'*(1+rho^2));
7   xbasc();
8   if fstyle=='new' then 
9     f=gcf();
10     f.color_map=hotcolormap(128);
11     f.background= 128;
12     f.foreground=1;
13     a=gca();
14     a.background= 128;
15     a.foreground=1;
16   else
17     xset('colormap',hotcolormap(128))
18     xset('background',xget('white'))
19   end
20   graypolarplot(theta,rho,z)
21   return
22 end
23
24
25 R=max(rho)
26 nv=size(varargin)
27 if nv>=1 then strf=varargin(2),else  strf='030',end
28 if nv>=2 then rect=varargin(4),else  rect=[-R -R R R]*1.1,end
29 if fstyle=='new' then 
30   drawlater()
31 end
32 plot2d(0,0,1,strf,' ',rect)
33
34 [rho,k]=sort(rho);z=z(:,k);
35
36 nt=size(theta,'*');theta=matrix(theta,1,-1)*180/%pi
37 for k=1:size(rho,'*')-1
38   r=rho(k)
39   xfarcs([-r*ones(1,nt-1);
40            r*ones(1,nt-1)
41            2*r*ones(1,nt-1)
42            2*r*ones(1,nt-1)
43            theta(1:$-1)*64;
44            (theta(2:$)-theta(1:$-1))*64
45            ],(z(1:$-1,k)+z(2:$,k)+z(1:$-1,k+1)+z(2:$,k+1))/4)
46 end
47 r=rho($)
48 if r<>0 then
49   xfarcs([-r;r;2*r;2*r;0;360*64],xget('background'))
50 end
51
52 step=R/5
53 r=step;dr=0.02*r;
54 for k=1:4
55   xset("dashes",3)
56   xarc(-r,r,2*r,2*r,0,360*64)
57   xset("dashes",1)
58   xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12),string(round(10*r)/10))
59   r=r+step
60 end
61 xset("dashes",1)
62 xarc(-r,r,2*r,2*r,0,360*64)
63 xstring((r+dr)*cos(5*%pi/12),(r+dr)*sin(5*%pi/12),string(round(10*r)/10))
64
65 rect=xstringl(0,0,'360');w=rect(3);h=rect(4);d=sqrt(w^2+h^2)/1.8
66 r=R+d
67 for k=0:11
68   xset("dashes",3)
69   xsegs([0;R*cos(k*(%pi/6))],[0;R*sin(k*(%pi/6))])
70   xset("dashes",1)
71   xstring(r*cos(k*(%pi/6))-w/2,r*sin(k*(%pi/6))-h/2,string(k*30))
72 end
73 xset("dashes",1)
74 if fstyle=='new' then drawnow(),end
75 endfunction