Circular time plots using polarhistogram?

Hi there,
I don't know how to make circular plots in Matlab. They can provide insight into patterns of activity based on time of day and are frequently used in research articles (like the attached figure). Is it possible to use polarhistogram to draw it? Thanks for your comments and suggestions!

 Accepted Answer

Suppose you have the wind direction in degrees at 1 minute intervals for 1 day:
windDir=360*rand(1,1440);
Make a histogram of the wind:
polarhistogram(windDir)
Maybe you don;t like that histogram because the degrees do not look like a compass. Suppose also that you want the histogram to have 15 degree segments (pi/12) instead of 30 degrees. Make those fixes as follows::
figure; polarhistogram(windDir, 'BinWidth',pi/12)
set(gca,'ThetaZeroLocation','top','ThetaDir','clockwise');
Good luck!

3 Comments

Here is a followup with a polar plot showing activity at each hour of the day.
We have activity level each hour:
activity=rand(1,24); %activity at each hour
activity=[activity,activity(1)]; %copy hour 0 data to the end
theta=(0:24)*2*pi/24; %angles corresponding to 0 to 24 hours
[xb, yb]=stairs(theta,activity);
polarplot(xb,yb)
I used stairs() to make a plot with flat segments within each hour, like the screenshot in your original posting. The code above does not make quite the plot you want, bcasuse you want hours around the circle, with 0 at the top. Here is how to fix those issues:
figure; polarplot(xb,yb);
set(gca,'ThetaZeroLocation','top','ThetaDir','clockwise');
thetaticks(0:15:360);
thetaticklabels({'0','1','2','3','4','5','6','7','8','9','10','11','12',...
'13','14','15','16','17','18','19','20','21','22','23','24'});
Good luck.
Truely nice, thank you very much

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020b

Community Treasure Hunt

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

Start Hunting!