Make polar histogram bins on cardinal axes

5 views (last 30 days)
I am making a polar histogram showing eye movement directions. I would like each bin to represent each tick rather than representing the directions between the ticks. It is correct at 0, but incorrect at 90, 180, and 270, as shown here. How do I change it so that the bins represent cardinal directions at 0, 90, 180, and 270?
My code is very simple, the line is simply: "polarhistogram(saccade.AngularDirections,15)" where saccade is a table, and AngularDirections is a column of numbers with different directions in radians.
Thank you in advance!

Accepted Answer

Scott MacKenzie
Scott MacKenzie on 6 May 2021
Edited: Scott MacKenzie on 10 May 2021
Consider specifying bin edges rather than the number of bins. If you want four bins centered at 0, 90, 180, and 270, then you need to specify five edges. In the example below, the edges are 0 90 180 270 360, but offset by 45 degrees. This gives you four bins centered at 0, 90, 180, and 270 degrees. Is that what you want?
% test data
y = 2*pi * rand(1,100);
edges = (0:90:360) + 45;
edges = deg2rad(edges);
polarhistogram(y, edges);
Additional details are in my answer to this question, which you had commented on.

More Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!