Annular polar plot with an offset origin

12 views (last 30 days)
Hi,
Is it possible to create a polar plot with an offset origin, such as it creates an "annulus" (examples below)?
Thank you for you help.
  1 Comment
Adam Danz
Adam Danz on 17 Aug 2021
Edited: Adam Danz on 17 Aug 2021
No, Matlab does not have a method of producing the first plot you shared. You could produce two separate plots for the blue and red segments and then combine them using an image editor. For example, you could set thetalim to limit the range of angular values.

Sign in to comment.

Accepted Answer

Dave B
Dave B on 17 Aug 2021
As @Adam Danz describes above, there's no built in way to do either the annulus part or the wedge part.
But, as with many things in MATLAB graphics, if you really wanted to, you could fake it:
  • You can fake the center 'hole' with another polaraxes.
  • Getting clipping on the outer border like you have in the chart on the right would be tricky (bubblecharts do this in Cartesian but not Polar axes).
  • For the one on the left you could drop ticks in the unlabeled wedges and add a few stronger lines to box in the wedges.
Here's some messy (off the top of my head) code to get started if you're eager to hack some simulated annular plots:
t=tiledlayout(1,2);
nexttile
th=linspace(pi/3,5*pi/6,100);
r=smooth(2*rand(1,100)+3,10);
polarplot(th,r,'b','linewidth',2);
hold on
polarplot([min(th) min(th)],[2 6],'k-')
polarplot([max(th) max(th)],[2 6],'k-')
polarplot(linspace(min(th),max(th),50),repelem(6,50),'k-')
rticks(2:6)
p1=gca;
p1.RMinorGrid='on';
p1.RAxis.MinorTickValues=2.5:5.5;
p1.ThetaMinorGrid='on';
p1.ThetaAxis.MinorTickValues=[75:30:135 247.5:15:302.5];
th=linspace(4/3*pi,2*pi,100);
r=smooth(2*rand(1,100)+3,10);
polarplot(th,r,'r','linewidth',2);
rlim([0 6])
thetaticks([60:30:150 240:15:360])
polarplot([min(th) min(th)],[2 6],'k-')
polarplot([max(th) max(th)],[2 6],'k-')
polarplot(linspace(min(th),max(th),50),repelem(6,50),'k-')
p2=polaraxes;
rticks([])
thetaticks([])
cx=p1.Position(1)+p1.Position(3)/2;
cy=p1.Position(2)+p1.Position(4)/2;
p2.Position=[cx-.065 cy-.065 .13 .13];
hold on
polarplot(linspace(0,2*pi,100),ones(1,100),'k-','linewidth',1)
rlim([0 1])
nexttile(t)
th=rand(1,100)*2*pi;
r=2*rand(1,100)+3;
polarbubblechart(th,r,r,th)
rlim([0 6])
bubblesize([1 10])
rticks(3:.5:6);
p1=gca;
hold on
polarplot(linspace(0,2*pi,100),repelem(max(rlim),100),'k-','linewidth',1)
colormap turbo
drawnow
p2=polaraxes;
rticks([])
thetaticks([])
cx=p1.Position(1)+p1.Position(3)/2;
cy=p1.Position(2)+p1.Position(4)/2;
p2.Position=[cx-.1 cy-.1 .2 .2];
%p2.LineWidth=1;
hold on
polarplot(linspace(0,2*pi,100),ones(1,100),'k-','linewidth',1)
rlim([0 1])

More Answers (1)

Drepanon
Drepanon on 20 Aug 2021
Thanks for your answer, will try that.

Categories

Find more on Polar Plots in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!