Changing the radial axislabels in a polar plot

조회 수: 1 (최근 30일)
Jakob Sievers
Jakob Sievers 2011년 11월 8일
답변: Ramez hamid 2014년 11월 27일
Hi guys
Plenty of questions have been asked here regarding changing the axislabels in a polarplot. They have, as far as I can see, all focused on the circumferential axislabels (i.e.: for instance changing 0,90,180,etc. to N,E,S,etc.).
I am however trying to change the radial labels and I cant seem to find any previously mentioned solutions which do the trick ( This is an example i tried following but with no success.). I'm plotting values that lie between 0 and 2, thus resulting in the labels: 0.5, 1.0, 1.5 and 2.0. How can I change these?
Thanks in advance

채택된 답변

Jonathan
Jonathan 2011년 11월 8일
Jakob,
This is a necessarily, I think, imprecise process. That is, this method may become invalid with later distributions of Matlab. I have found that the labels in your particular situation start with two spaces. This is a quite volatile piece of information to use, but it gets the job done. Here is my code to setup the labels.
% Get figure and axes
fHand = figure;
aHand = axes('parent', fHand);
% Make sure limits are correct.
pHand = polar(0, 2, 'parent', aHand);
delete(pHand)
% Get the handles of interest (using volatile info above).
hands = findall(fHand,'parent', aHand, 'Type', 'text');
hands = hands(strncmp(' ', get(hands,'String'), 2));
hands = sort(hands);
% Relabel from inside out.
labels = {'label one', 'label two', 'label three', 'label four'}
for i = 1:4
set(hands(i),'String', labels{i})
end
% Make sure to 'hold on' to keep your labels before plotting.
hold on
t = 0:.01:2*pi; polar(t,4*sin(2*t).*cos(2*t),'--r', 'parent', aHand);
I hope this helps.
~Jonathan

추가 답변 (1개)

Ramez hamid
Ramez hamid 2014년 11월 27일
Hello folks
Please I would like to know how can I change the positions of the Rho labels in a polar plot?
Many thanks

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by