ang = deg2rad(linspace(0,360,24));% angles
vals = 1:24; % values
% convert the values to vector components
U = vals.*cos(ang);
V = vals.*sin(ang);
% plot:
hp = compass(U,V);
你得到:
但是,如果你想要酒吧而不是箭头,那就更棘手了 . 从上面绘制 hp 后,您应该执行以下操作:
% get all X and Y data from the plot:
arrowsX = cell2mat(get(hp,'XData'));
arrowsY = cell2mat(get(hp,'YData'));
% delete all arrows head values:
set(hp,{'XData'},num2cell(arrowsX(:,1:2),2));
set(hp,{'YData'},num2cell(arrowsY(:,1:2),2));
% make the lines look like bars:
set(hp,{'LineWidth'},num2cell(ones(24,1)*6));