1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| function radargraph4bar(P)
if nargin==0
P = [1 6.5 2.5 ; 5.5 3 1.5 ; 7 2 1];
end
[nPVal,nP] = size(P);
th = linspace(0,2*pi,nPVal+1);
r = linspace(0,sum(P(1,:)),6);
x = sin(th(:));
y = cos(th(:));
% Set backgound color to white
fill(x*r(end),y*r(end),'w');
hold on
% Draw concentric lines
line(x*r(2:end),y*r(2:end), ...
'color','k', ...
'linestyle',':');
C = cumsum(P,2);
ep = .5;
cmap = hsv(nP);
for n = 1:nPVal
p(1) = patch('xdata',[-ep -ep ep ep],'ydata',[0 C(n,1) C(n,1) 0],'facecolor',cmap(1,:));
for k = 2:nP
p(k) = patch('xdata',[-ep -ep ep ep],'ydata',[C(n,k-1) C(n,k) C(n,k) C(n,k-1)],'facecolor',cmap(k,:));
end
rotate(p,[0 0 1],th(n)*180/pi,[0 0 0])
end
axis equal |
Partager