plotting windrose using Matlab
Show older comments
Hi , can someone please help me with windrose plotting . I have directions and windspeed as my first and second column, and using wind_rose.m which I got from Matlab fileexchange Thanks S
Accepted Answer
More Answers (1)
Hello,
If you use the polarhistgram function you can index on wind speed and overlay to your hearts content -
figure
pax = polaraxes;
polarhistogram(deg2rad(wind_direction(wind_speed<25)),deg2rad(0:10:360),'displayname','20 - 25 m/s')
hold on
polarhistogram(deg2rad(wind_direction(wind_speed<20)),deg2rad(0:10:360),'FaceColor','red','displayname','15 - 20 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<15)),deg2rad(0:10:360),'FaceColor','yellow','displayname','10 - 15 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<10)),deg2rad(0:10:360),'FaceColor','green','displayname','5 - 10 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<5)),deg2rad(0:10:360),'FaceColor','blue','displayname','0 - 5 m/s')
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'top';
legend('Show')
title('Wind Rose')
Note, my data was in degrees. Remove deg2rad if yours is in radians.
2 Comments
Isabella Osetinsky-Tzidaki
on 1 Jan 2025
I was happy to find the above code, but needed to modify it for my purposes, because:
1) I was having to define 16 wind direction sectors;
2) I didn't find any quick solution how to update the 12 default WD grid and the corresponding 12 WD ticks into 16 WD ticks. So I needed to merely set the grid and the ticks "off".
3) my biggest problem was to combine the WD just left to and right to the north direction to get a purely northern sector. So I defined the upper WD edge beyond the 0/360 to make it to coincide with the first WD edge: 11.25 deg = 371.25 deg (which is 11.25 deg plus 2*pi).
Finally, I set the 'renderer' to 'painters' to improve the figure quality.
Happily, all these modifications provided me with a good solution and a good figure.
One more point: as was showed by a simple histogram for WS, my max WS is 30.6 m/s while a bulk of the WS is below 10 m/s.
Below is the above code with my modifications:
vecWD=11.25:22.5:371.25;
% max WS = 30.6 m/s
polarhistogram(deg2rad(wind_direction(wind_speed<31)),deg2rad(vecWD),'FaceColor',[158/255 0 0],'displayname','> 10 m/s')
hold on
polarhistogram(deg2rad(wind_direction(wind_speed<10)),deg2rad(vecWD),'FaceColor',[1 102/255 0],'displayname','8 - 10 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<8)),deg2rad(vecWD),'FaceColor','yellow','displayname','6 - 8 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<6)),deg2rad(vecWD),'FaceColor','green','displayname','4 - 6 m/s')
polarhistogram(deg2rad(wind_direction(wind_speed<4)),deg2rad(vecWD),'FaceColor','blue','displayname','< 4 m/s')
hold off
pax.ThetaDir = 'clockwise';
pax.ThetaZeroLocation = 'top';
legend('Show')
title('Wind Rose')
set(gca,'thetagrid','off')
set(gca,'thetaticklabels',{' '})
set(gca,'rticklabels',{' '})
set(gcf,'ren','painters')
Abigail Hobbs
on 4 Mar 2025
Hi! I am also working on generating wind roses. I have been struggling to find a way to color by polar coordinate sector - have you come across a way to do this? Trying to color by both wind speed and wind direction. Thank you!
Categories
Find more on Geographic 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!