Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a title appear above a polar plot in MATLAB

Tags:

matlab

title

I have created a simple polar plot like this:

polar(direction, power, 'k.')  
title('this is my title')

Only the title overlaps the numbers at the top of the circle.

How do I shift the plot down / title up or create room to do so? I would have thought MATLAB would adjust itself automatically?

like image 384
user2225869 Avatar asked Oct 21 '22 12:10

user2225869


1 Answers

You can modify the call to title so that it returns a handle, which you can then use to adjust the position.

t = title('this is my title');
get(t,'Position')
ans =
   -0.0024    1.1810    1.0001
set(t,'Position',get(t,'Position')+[0 .01 0]);  % move up slightly

The default position of the title is expressed as a fraction relative to the current plot axes, which are based on the figure window size. So you may see overlap if the window is small. Enlarging the window may solve the problem for you without the need for doing anything else.

You can also shift the plot around by adjusting its Position -- but since the title's position is fixed to the plot axes, the title will just shift with the plot. But this can be useful with the solution above if the space above the plot is crowded.

get(gca,'Position')
ans =
    0.1300    0.1100    0.7750    0.8150
set(gca,'Position',[.13,.10,.775,.815]);  % move plot down a bit

For what it is worth, you can also place text in an arbitrary position using the 'text' command.

like image 63
nhowe Avatar answered Oct 24 '22 02:10

nhowe