Annular polar plot with an offset origin

조회 수: 12 (최근 30일)
Drepanon
Drepanon 2021년 8월 17일
답변: Drepanon 2021년 8월 20일
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
Adam Danz
Adam Danz 2021년 8월 17일
편집: Adam Danz 2021년 8월 17일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Dave B
Dave B 2021년 8월 17일
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])

추가 답변 (1개)

Drepanon
Drepanon 2021년 8월 20일
Thanks for your answer, will try that.

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by