Polarplot axis label: how to edit the value?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
Expert,
Can anyone tell me how is it possible to change the radial axis label in polarplot function? I want the original label to be subtracted by certain value, e.g. 1.0
I just to manipulate the axis label, without changing the value of the data or result. Thus, the plot will essential remain the same, just the label is "manipulated".
Suppose I have the following data:
x = linspace(0,2*pi);
y = cos(x)+ sin(x);
polarplot(x,y)
The results of that function is

Now, what I want is to change the original axis label [0 0.5 1.0 1.5] into [-1 -0.5 0 0.5].
How can we do that?
This is what I expect

채택된 답변
dpb
2018년 12월 21일
hPP=polarplot(x,y); % plot, save handle
hPA=hPP.Parent; % retrieve polar axes handle (parent of polar plot)
hPA.RTickLabel=hPA.RTick-1; % rewrite radius tick labels as desired
hPA.RColor='r'; % change color
댓글 수: 11
Thanks @dpq
More question:
- How is it possible to remove the first label? i.e. the -1?
- How to control the number of label displayed in the polar plot?
madhan ravi
2018년 12월 21일
편집: madhan ravi
2018년 12월 21일
rticks([0.5 1.0 1.5])
rticklabels([-0.5 0 0.5])
BeeTiaw
2018년 12월 21일
Hi Madhan Ravi, this can only be done if the label is known.
What I am after is for a general case, i.e. I don't have any prior information about the label. So, how to ignore just the first element of the label?
As with all other axes, the tick labels can be set independently of the tick values as far as content but there must be a tick at any given location to label. For the first to just not display one, you simply
Rlab=hPA.RTickLabel; % retrieve existing tick labels
Rlab{1}=''; % clear the one don't want
hPA.RTickLabel=Rlab; % and rewrite
NB: the size of the tick label array must match the size of the tick array or the labels will either not all be displayed (longer) or the elements will be repeated as needed to label all ticks (shorter).
Second question is combination of the above, depending on the effect you're after -- more ticks means set the .RTick property to have the number/spacing you wish; to leave the number the same but the number of displayed labels is the first (note you can this way only have the same number or fewer labels than ticks; you can't have more labels than ticks).
Read the documentation on axes and axes properties for more details...
Thanks again dpb,
But this line:
Rlab{1} = ' ';
in the code gives me error. It says "unable to perform assignment because brace indexing is not supported for variables of this type"
How can I fix this?
Dunno...what type is Rlab on your system? It's a cell array here with ML R2017b so that works just peachy-keen...
>> hP=polarplot(x,y);
>> hPA=hP.Parent;
>> Rlab=hPA.RTickLabel;
>> whos Rlab
Name Size Bytes Class Attributes
Rlab 4x1 464 cell
>> Rlab{1}=''
Rlab =
4×1 cell array
{0×0 char}
{'0.5' }
{'1' }
{'1.5' }
>>
What do you see different there and which release of ML you running?
Rlab is char in my case
whos Rlab
Name Size Bytes Class Attributes
Rlab 3x4 24 char
>> Rlab
Rlab =
3×4 char array
'-1 '
'-0.5'
'0 '
It works fine now after converting the char into cell into your original code:
hP=polarplot(x,y);
hPA=hP.Parent;
Rlab=hPA.RTickLabel;
Rlabstr = cellstr(Rlab);
Rlabstr{1}=''; % clear the one don't want
hPA.RTickLabel=Rlabstr; % and rewrite
Thank you for your kind help dpb!
The code gives me what I want now.
What release of ML???
I've never seen the dot notation return a char array in such a use--is that really the exact code? That's bizzaro, if so.
I think you'd already cleared the first row elements before by the output shown because it's
>> whos Rlab
Name Size Bytes Class Attributes
Rlab 3x4 24 char
>>
and is already 3x4 instead of 4x4 elements as it would be if hadn't already eliminated the first element. I think you inadvertently must have done something else to have caused the conversion from cell array to char array.
I just reran the sample here and even after clearing the first label content in the cell array and rewriting, as expected if one retrieves the new 'RTickLabel' content, it's still a cell array of four elements.
@dpb Thanks for the answer. Is it possible to modify the fontsize of rticks only ?
dpb
2022년 5월 25일
No, 'FontSize' is only one property for the polar axes object -- follow the links from the "See Also" link to the section on properties for the object -- or save the axes handle and click on the "show all properties" link that shows up in the command window if you display the handle value interactively.
추가 답변 (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)
