Skip to content

Commit 419b4fb

Browse files
authored
Add files via upload
1 parent d05f5c1 commit 419b4fb

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

Example.mlx

143 KB
Binary file not shown.

polarPcolor.m

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
p.addOptional('Rscale','linear');
7070
p.addOptional('colormap','parula');
7171
p.addOptional('ncolor',[]);
72+
p.addOptional('typeRose','meteo'); % 'meteo' or 'default'
7273
p.addOptional('circlesPos',[]);
7374
p.parse(varargin{:});
7475

@@ -82,6 +83,8 @@
8283
myColorMap = p.Results.colormap ;
8384
ncolor = p.Results.ncolor ;
8485
circPos = p.Results.circlesPos ;
86+
typeRose = p.Results.typeRose ;
87+
8588

8689
if ~isempty(circPos)
8790
Origin = max([min(circPos),min(R)]);
@@ -193,8 +196,16 @@ function createSpokes(thetaMin,thetaMax,Ncircles,circlesPos,Nspokes)
193196
end
194197
contourD = abs((circleMesh - circleMesh(1))/Rrange+R(1)/Rrange);
195198

196-
cost = cosd(90-spokeMesh); % the zero angle is aligned with North
197-
sint = sind(90-spokeMesh); % the zero angle is aligned with North
199+
if strcmpi(typeRose,'meteo')
200+
cost = cosd(90-spokeMesh); % the zero angle is aligned with North
201+
sint = sind(90-spokeMesh); % the zero angle is aligned with North
202+
elseif strcmpi(typeRose,'default')
203+
cost = cosd(spokeMesh); % the zero angle is aligned with east
204+
sint = sind(spokeMesh); % the zero angle is aligned with east
205+
else
206+
error('"type" must be "meteo" or "default" ');
207+
end
208+
198209
for kk = 1:Nspokes
199210

200211
X = cost(kk)*contourD;
@@ -255,7 +266,19 @@ function createCircles(rMin,rMax,thetaMin,thetaMax,Ncircles,circlePos,Nspokes)
255266

256267

257268
% define the grid in polar coordinates
258-
angleGrid = linspace(90-thetaMin,90-thetaMax,100);
269+
270+
271+
if strcmpi(typeRose,'meteo')
272+
angleGrid = linspace(90-thetaMin,90-thetaMax,100);
273+
elseif strcmpi(typeRose,'default')
274+
angleGrid = linspace(thetaMin,thetaMax,100);
275+
else
276+
error('"type" must be "meteo" or "default" ');
277+
end
278+
279+
280+
281+
259282
xGrid = cosd(angleGrid);
260283
yGrid = sind(angleGrid);
261284

@@ -272,6 +295,10 @@ function createCircles(rMin,rMax,thetaMin,thetaMax,Ncircles,circlePos,Nspokes)
272295

273296
position = 0.51.*(spokeMesh(min(Nspokes,round(Ncircles/2)))+...
274297
spokeMesh(min(Nspokes,1+round(Ncircles/2))));
298+
299+
if strcmpi(typeRose,'meteo'),position = 90-position; end
300+
301+
275302

276303
if isempty(RtickLabel),
277304
rtick = num2str(tickMesh(kk),2);
@@ -280,28 +307,28 @@ function createCircles(rMin,rMax,thetaMin,thetaMax,Ncircles,circlePos,Nspokes)
280307
end
281308
if abs(round(position)) ==90,
282309
% radial graduations
283-
text((contourD(kk)).*cosd(90-position),...
284-
(0.1+contourD(kk)).*sind(86-position),...
310+
text((contourD(kk)).*cosd(position),...
311+
(0.1+contourD(kk)).*sind(position-4),...
285312
rtick,'verticalalignment','BaseLine',...
286313
'horizontalAlignment', 'center',...
287314
'handlevisibility','off','parent',cax);
288315
% annotate spokes
289-
text(contourD(end).*0.6.*cosd(90-position),...
290-
0.07+contourD(end).*0.6.*sind(90-position),...
316+
text(contourD(end).*0.6.*cosd(position),...
317+
0.07+contourD(end).*0.6.*sind(position),...
291318
[labelR],'verticalalignment','bottom',...
292319
'horizontalAlignment', 'right',...
293320
'handlevisibility','off','parent',cax);
294321
else
295322
% radial graduations
296-
text((contourD(kk)).*cosd(90-position),...
297-
(contourD(kk)).*sind(90-position),...
323+
text((contourD(kk)).*cosd(position),...
324+
(contourD(kk)).*sind(position),...
298325
rtick,'verticalalignment','BaseLine',...
299326
'horizontalAlignment', 'right',...
300327
'handlevisibility','off','parent',cax);
301328

302329
% annotate spokes
303-
text(contourD(end).*0.6.*cosd(90-position),...
304-
contourD(end).*0.6.*sind(90-position),...
330+
text(contourD(end).*0.6.*cosd(position),...
331+
contourD(end).*0.6.*sind(position),...
305332
[labelR],'verticalalignment','bottom',...
306333
'horizontalAlignment', 'right',...
307334
'handlevisibility','off','parent',cax);

0 commit comments

Comments
 (0)