Question

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:

An example of what I want to do.

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.

Was it helpful?

Solution

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)]);

enter image description here

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top