Changing bin edges on polar histogram
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am making a polar histogram showing wind directions. I would like each bin to represent each tick rather than representing the directions between to ticks as shown below. How do I change that, so e.g. the bin representing North takes value from [337.5 : 22.5]?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/189553/image.png)
1 Kommentar
Stephanie Reeves
am 21 Apr. 2021
I realize this was posted two years ago, but did you find the answer? I have the same problem. Currenting Googling and have come up with nothing. :/ Thank you!
Antworten (1)
Scott MacKenzie
am 6 Mai 2021
Bearbeitet: Scott MacKenzie
am 6 Mai 2021
I suggest you work with bin edges in addition to the number of bins. Below are two examples. On the right, the bins are wind directions, as in your example, with the bins centered in each compass point.
% test data
y = 2*pi * rand(1,100);
tiledlayout('flow');
nexttile;
n = 8; % number of bins
binTheta = 360 / n;
edges = (0:binTheta:360) + binTheta/2;
edges = deg2rad(edges);
polarhistogram(y, edges);
nexttile;
n = 16; % number of bins
labels = { 'E', 'ENE', 'NE', 'NNE', 'N', 'NNW' 'NW', 'WNW', 'W', ...
'WSW', 'SW', 'SSW', 'S', 'SSE', 'SE', 'SES'};
binTheta = 360 / n;
edges = (0:binTheta:360) + binTheta/2;
edges = deg2rad(edges);
polarhistogram(y, edges);
ax = gca;
ax.ThetaTick = 0:binTheta:360;
ax.ThetaTickLabels = labels;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/609615/image.jpeg)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!