Can I draw a section of a polar plot?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Is it possible to draw only part of a polar plot? That is, when the centre of the plot is outside the viewed plot.
I have a plot of some data close to the Earth's surface, and I want to draw it with the real curvature of the surface. I could do the transformations manually, but I thought a polar plot would be a better way.
Here is my plot.

채택된 답변
Well, sorta', but not totally generic.
hPax=polaraxes('thetalim',[0 20],'thetazerolocation','top','thetadir','clockwise','rlim',[0 300],'rdir','reverse');

may be something like what you're envisioning, but the 'thetazerolocation' parameter is only one of the four quadrants, it can't be set as an angle to make the 10-degree radius vertical as you would probably prefer. You also can't change the aspect ratio to make the subtended angle fill the total figure/axes space; it is constrained to be only the fraction of the full circle given by the 'thetalim' range.
But, you can make the theta axis symmetric about zero
figure
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 300],'rdir','reverse');

and then relabel manually as desired. To plot into the latter, of course, you would have to center your data to match the actual ThetaTick values; the labels now are purely artificial and not the same as the actual tick values.
figure
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 300],'rdir','reverse');
hPax.ThetaTickLabel=hPax.ThetaTick+10;

Whether that's useful or not you'll have to decide, is about the closest "out of the box" I think you could get with builtin MATLAB functions.
댓글 수: 8
dormant
2023년 9월 1일
Thanks very much. That's a good start.
dormant
2023년 9월 1일
I still have a problem. I only want to show the top of the plot, as the attached sketched file illustrates on the right. (I'm away from my MATLAB computer).

Can that be done?
Not with the polar axes object, no, it will always put the range of the 'rlim' values at the center/outer radius locations. You could increase the range to compress larger magnitudes towards the outer rim by increasing the limits range...
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 1500],'rdir','reverse');
hPax.ThetaTickLabel=hPax.ThetaTick+10;
hPax.RTick=[0:150:300];

But you would then have to draw an opaque circle over it to occlude the inner rays and otomh I don't know that you can manage to do that on top of the polar axis object or not...it simply doesn't know about anything except the full slice over the theta limits range; it doesn't have a similar property for r range; it can only set the limits of the ends of the ray, it can't truncate it.
Try this...
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 1500],'rdir','reverse');
hPax.ThetaTickLabel=hPax.ThetaTick+10;
hPax.RTick=[0:150:300];
hold on
rng=rlim;
hPSc=polarscatter(hPax,0,rng(end),1.63*100000,'w','filled');

The scatter size is in points instead of in radius units (PLEASE, TMW, give us the option) so it's trial & error to find the size that comes close but doesn't overwrite the labels because polorscatter doesn't honor the range of the polar axes object into which it is drawn (set the color to 'k' instead of 'w' and rerun). This seems to be a quality of implementation issue that could be worth of enhancement/bug report; seems to me it ought to be clipped at the theta limits.
You can do something close. Specify the RLim, RDir, and RTick properties when you create your polaraxes. See the properties documentation page for more information about these properties.
ax = polaraxes('RLim', [0 6371], ...
'RDir', 'reverse', ...
'RTick', [0 150 300], ...
'ThetaLim', [-30 30]);

I don't believe you can eliminate the point at the center of the polar axes.
dpb
2023년 9월 1일
@Steven Lord, see my workaround posted just a few minutes before your note.
You're correct that cannot eliminate the center; the range for r isn't settable, only the limits assocaiated with the center/outer points. Could be an enhancement request, maybe???
You can create an appearance of having done so as shown by plotting on top of the axes to occlude the center section; of course this has the same problem as far as the object size goes of not expanding the visible plot to fill the area of the axes; it remains the same, just more white space inside the figure.
It also has an issue that neither polarscatter nor bubblechart honor the theta clipping limits of the parent axes. This seems to me to be an issue worthy of addressing.
"this has the same problem as far as the object size goes of not expanding the visible plot to fill the area of the axes"
Of course, you can expand the axes to be partially outside the figure.
figure('Color','r') % red figure so you can see it here
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 1500],'rdir','reverse');
hPax.ThetaTickLabel=hPax.ThetaTick+10;
hPax.RTick = 0:150:300;
hPax.Position([2 4]) = [-2 2.815];

And, if you want, obscure the bottom visible part of the axes with another object:
f = figure('Color','r'); % red figure so you can see it here
hPax=polaraxes('thetalim',[-10 10],'thetazerolocation','top','thetadir','clockwise','rlim',[0 1500],'rdir','reverse');
hPax.ThetaTickLabel=hPax.ThetaTick+10;
hPax.RTick = 0:150:300;
hPax.Position([2 4]) = [-2 2.815];
uicontrol(f,'Style','text','BackgroundColor',f.Color,'Units','normalized','Position',[0 -0.01 f.Position(3) 0.1]);

dormant
2023년 9월 4일
Many thanks for all this. I've used dpb's suggestion.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
