0
$\begingroup$

I hope this is not off-topic. I'm wondering is there anyway to change the default angle unit label in MATLAB polar plot. The default angle label is from 0 to 360, at 30 increment. It goes like 0,30,60,... But I want to change it, say, from 0 to -360, at -30 increment. So the labels will be like 0,-30,-60,... Is there anyway to do it?

$\endgroup$
1
$\begingroup$

When you opens the polar plot in the figure editor you can find out that the coordinates around the plot are not from the axis. It are hidden text objects (Press on one you see it). So this means you have to edit them by yourself. a work around for this is this:

figure
t = 0:.01:2*pi;
polar(t,sin(2*t).*cos(2*t),'--r')

hHiddenText = findall(gca,'type','text');
Angles = 0 : 30 : 330;
hObjToDelete = zeros( length(Angles)-4, 1 );
k = 0;
for ang = Angles
   hObj = findall(hHiddenText,'string',num2str(ang));
   switch ang
   case 0
      set(hObj,'string','0');
   case 30
      set(hObj,'string','-30');
   case 60
      set(hObj,'string','-60');
   case 90
      set(hObj,'string','-90');
   case 120
      set(hObj,'string','-120');
   case 150
      set(hObj,'string','-150');
   case 180
      set(hObj,'string','-180');
   case 210
      set(hObj,'string','-210');
   case 240
      set(hObj,'string','-240');
   case 270
      set(hObj,'string','-270');
   case 300
      set(hObj,'string','-300');
   case 330
      set(hObj,'string','-330');
   otherwise
      k = k + 1;
      hObjToDelete(k) = hObj;
   end
end
delete( hObjToDelete(hObjToDelete~=0) );

If you want other directions etc i think you do that manually otherwise the plot start tot mess up.

$\endgroup$
  • $\begingroup$ That solves the problem. Thank you! @Jan-Bert $\endgroup$ – sgyf Apr 26 '15 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.