MATLAB Answers

Changing the radial axislabels in a polar plot

5 views (last 30 days)
Jakob Sievers
Jakob Sievers on 8 Nov 2011
Answered: Ramez hamid on 27 Nov 2014
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

Accepted Answer

Jonathan
Jonathan on 8 Nov 2011
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

More Answers (1)

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

Community Treasure Hunt

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

Start Hunting!