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.

 채택된 답변

dpb
dpb 2023년 8월 31일
편집: dpb 2023년 8월 31일

0 개 추천

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
dormant 2023년 9월 1일
Thanks very much. That's a good start.
dormant
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
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.
Voss
Voss 2023년 9월 1일
편집: Voss 2023년 9월 1일
"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
dormant 2023년 9월 4일
Many thanks for all this. I've used dpb's suggestion.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Polar Plots에 대해 자세히 알아보기

제품

릴리스

R2023a

태그

질문:

2023년 8월 31일

댓글:

2023년 9월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by