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