Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab Query: How to align 'title' at the botton of the figure when plotting points

Tags:

plot

matlab

title

My question says everything. I am plotting points on Matlab. But when I set 'title' value, it displays title-name at the top of the image by default. How can I get the title set a the bottom of the image?

Thanks in advance.

like image 579
user990479 Avatar asked Nov 12 '11 00:11

user990479


2 Answers

If you don't use xlabel you could use that as a quick hack.

If you do use the xlabel, add another line or two by passing a cell array:

figure;
xlabel({'X-label', '', 'Figure title'});

As Amro mentioned in his comments you can make a text anywhere with uicontrol:

x=linspace(0,10*pi);
plot3(x,x.*cos(x),x.*sin(x)); % Plot a 3d spiral
uicontrol('Style','text','Position', [200 20 200 20],'String','My Title')

The positioning is not automatic, so when you resize the figure, the title will move away from the center.

like image 130
Kleist Avatar answered Oct 02 '22 23:10

Kleist


Another possibility is to move the x-axis on top, and bring the title to bottom:

plot(rand(10,1))
h = xlabel('');     pos = get(h,'Position'); delete(h)
h = title('title'); set(h,'Position',pos);
set(gca, 'XAxisLocation','top')

screenshot

like image 34
Amro Avatar answered Oct 03 '22 00:10

Amro