Plot vector (or arc) onto a rose plot. MATLAB

点点圈 提交于 2020-01-24 19:22:27

问题


I have two datasets. One detailing a list of angles (which I am plotting onto a rose plot):

angles
-0.8481065519
0.0367932161
2.6273740453
...
n

The other, detailing directional statistics from this group of angles:

angle,error
-0.848106563,0.8452778824

Where angle essentially defines the directional mean, and error the circular variance, essentially an error bar either side of the angle

I have thus far plotted a rose histogram using the set of angles, as such:

h = rose(angles,36)

I would like to create a plot of the directional statistic angle (it does not need a length/magnitude - just to the edge of the circle plot) with the error around it. As an example:

I added the lines by hand in Matlab. If possible it would be good to perhaps have shading within the arc too. Alternatively, (and possibly preferred) would be to have just a sliver above the rose plot bins (so it doesn't cover the data) with a centre line (showing the angle and shading surrounding for the error.

Thanks in advance.


回答1:


How about this?

%// Data
angles = 2*pi*.8*randn(1,1e4);
angle = -0.848106563;
error = 0.8452778824;

%// Plot rose
rose(angles, 36);
axis image %// make axis square
hold on

%// Plot mean
a = axis;
a = a(2); %// size of axis
plot([0 cos(angle)*a], [0 sin(angle)*a], 'r')

%// Plot error as many shaded triangles that compose a circular wedge
t = linspace(-error/2+angle,error/2+angle,100); %// increase "100" if needed
for k = 1:numel(t)-1
    h = patch([0 cos(t(k))*a cos(t(k+1))*a 0], ...
        [0 sin(t(k))*a sin(t(k+1))*a 0], [.5 0 0], 'edgecolor', 'none');
        %// change color [.5 0 0] to something else if desired. Note also alpha
    set(h,'Facealpha',.3) %// make transparent
end     

%// Place rose on top by rearranging order of axis children
ch = get(gca,'children');
set(gca,'children',[ch(2:end); ch(1)]);

For this to work, you need to use a figure renderer capable of transparency. So you may need to adjust the figure's renderer property.



来源:https://stackoverflow.com/questions/23660867/plot-vector-or-arc-onto-a-rose-plot-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!