Histogram with circular bars

6 次查看(过去 30 天)
Joanna Smietanska
Joanna Smietanska 2019-10-10
Hi, I have data grouped into 100x3 and 100x4 matrices. Each matrix column refers to different types of measured angles, e.g. alpha, beta and so on. I prepared single polar histogram for first angle:
A = [160 65 200; 145 75 225; 160 50 250; 120 70 220]; % shortened version of one of 3-column matrices
[N, bin] = histcounts(A(:,1), 10, 'Normalization','probability');
minData = min(min(N));
maxData = max(max(N));
f = figure;
p1 = polarhistogram(A(:,1),10, 'Normalization','probability','FaceColor', 'b');
colorbar;
caxis([minData maxData]);
How can I plot content of each matrix into one polar probability histogram with concentric bins respective for each angle? I can't find out how to add other circular bins for subsequent angles. I would like to create something similar to this plot:
I will be very grateful for any advice and help.

回答(1 个)

Bjorn Gustavsson
Bjorn Gustavsson 2019-10-10
I would do something like this:
edges = 0:15:360;
N_all(1,:) = histcounts(M1,edges);% Put one histogram per row into N_all
N_all(2,:) = histcounts(M2,edges);
N_all(3,:) = histcounts(M3,edges);
N_all(4,:) = histcounts(M4,edges);
N_all(5,:) = N_all(4,:); % Replicate the last row
R = 1:5; % some arbitrary radial coordinates
theta = edges*pi/180; % angles in radians
try
polarPcolor(theta*180/pi,R,N_all),shading flat
catch
disp('You can find the polarPcolor function on the file exchange')
[theta,R] = meshgrid(theta,R);
pcolor(R.*cos(theta),R.*sin(theta),N_all),shading flat
end
HTH

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by