Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

figure title position, offset

1,946 views
Skip to first unread message

David Strozzi

unread,
Oct 28, 2004, 3:48:44 PM10/28/04
to
Hi,

I'm trying to get a good system in place for making matlab figures
that look nice in presentations. I've found nice figure size,
positions, font size, etc.

The snag is the title. It's too close to the plot. This is
especially a problem when '10^x' appears on the y-axis: it and the
title overlap.

How do you adjust the distance between the title and the top of what
you're graphing? I want to make this a default setting. So please
don't tell me the obvious, like 'just drag the title!'

What determines how high above the plot matlab puts the title? Can
this value be changed? I tried playing with the 'position' and
'outerPosition' axes property, to no avail.

Thanks.

the cyclist

unread,
Oct 28, 2004, 4:17:10 PM10/28/04
to

You can move it up a little by changing the Position attribute of the
Title object.

>> P = get(h,'Position')
>> set(h,'Position',[P(1) P(2)+0.3 P(3)])

The trouble is that if you move it up too far, it disappears off the
figure.

You might also consider adjusting the units of your y-axis variable
so that the '10^x' appendage does not appear on the plot.

the cyclist

unread,
Oct 28, 2004, 4:18:39 PM10/28/04
to
the cyclist wrote:

>>> P = get(h,'Position')
>>> set(h,'Position',[P(1) P(2)+0.3 P(3)])

Sorry, you also need, for example,

>> h = title('Very important plot')

David Strozzi

unread,
Oct 28, 2004, 5:39:18 PM10/28/04
to
Hi,

Thanks for the reply. I know how to do this, but what I want is an
_automated_ system. I want the title by default to be higher in the
figure window than it currently is. I don't want to have to do
something every time I make a figure.

Any ideas?

the cyclist wrote:

> You can move it up a little by changing the Position attribute of
> the
> Title object.
>

>>> P = get(h,'Position')
>>> set(h,'Position',[P(1) P(2)+0.3 P(3)])
>

the cyclist

unread,
Oct 28, 2004, 6:02:42 PM10/28/04
to
David Strozzi wrote:
>
>
> Hi,
>
> Thanks for the reply. I know how to do this, but what I want is an
> _automated_ system. I want the title by default to be higher in
> the
> figure window than it currently is. I don't want to have to do
> something every time I make a figure.
>
> Any ideas?

This can be automated, so that it is done every time the title is
placed. The only tricky part is knowing exactly the increment to
bump up the title. I will grant you that that might be very
annoying, but you might be able to scale it using the axis properties.

Alexis

unread,
Nov 13, 2012, 8:47:20 PM11/13/12
to
"the cyclist" <thecycl...@gmail.com> wrote in message <eeef...@webx.raydaftYaTP>...
(I know this is 8 years late, but hey, could be useful for someone else)

I think a good solution would be to create your own function that creates a title and moves it automatically.

Like this:
function myTitle(titleText)
h = title(titleText)
P = get(h,'Position')
set(h,'Position',[P(1) P(2)+0.3 P(3)])
end

So you can just do myTitle('Very Important Plot')

Nasser M. Abbasi

unread,
Nov 13, 2012, 9:14:53 PM11/13/12
to
On 11/13/2012 7:47 PM, Alexis wrote:

> I think a good solution would be to create your own function that creates
>a title and moves it automatically.
>
> Like this:
> function myTitle(titleText)
> h = title(titleText)
> P = get(h,'Position')
> set(h,'Position',[P(1) P(2)+0.3 P(3)])
> end
>
> So you can just do myTitle('Very Important Plot')
>


Do you not need to check what units are being used before
add '0.3' in there? may be get(gcf,'Units') or such? What
units is 0.3?

--Nasser

Paul Quinn

unread,
Jun 12, 2013, 4:17:09 PM6/12/13
to
"Nasser M. Abbasi" wrote in message <k7uuqu$uq0$1...@speranza.aioe.org>...
...
> > set(h,'Position',[P(1) P(2)+0.3 P(3)])
...
> Do you not need to check what units are being used before
> add '0.3' in there? may be get(gcf,'Units') or such? What
> units is 0.3?
....

I've tried changing 'position' like this. Two problems: 1) The Title moves around when you zoom or pan (right off the page). 2) If you save the figure to file, then open it again, the re-positioning is lost, and it just shows up in its default position again.

So the title 'position' seems to get recalculated a lot, as if the title were a piece of data.

I'm working on this now, and will check to see if 'units' = 'inches' will fix it (default is 'data'.) Or using 'Extent' instead of 'Position'.
...

Paul Quinn

unread,
Jun 12, 2013, 4:50:25 PM6/12/13
to
"Nasser M. Abbasi" wrote in message <k7uuqu$uq0$1...@speranza.aioe.org>...
...
> Do you not need to check what units are being used before
> add '0.3' in there? may be get(gcf,'Units') or such? What
> units is 0.3?
...

Units is the key to stabilizing the Title position. Here's what works for me:
tiHan = title(sprintf('%s',name),'Interpreter', 'none');
xyrange = axis;
set(tiHan, 'position', tiPos + [0 0.05 * (xyrange(4) - xyrange(3)) 0]); % move title up
set(tiHan, 'units', 'inches'); % so Title doesn't move on zoom.

Notes:
1) Default 'units' is 'data', which seems to treat Title like plottable x-y data. So when you move it, it's best to use a fraction of the range of your data, gotten from 'axis'.
2) After you change the units to 'inches', the title holds still (recalculates to the same position in the window) when you pan or zoom the data.
3) If you saveas fig, then reopen the saved figure, the title will be back in its old default position, but at least it will hold still for pan and zoom, even if you select and move it by hand (which destabilizes a normal title, of units= 'data').

Paul Quinn

unread,
Jun 12, 2013, 5:17:09 PM6/12/13
to
Correction to the previous post:

First add the line:
tiPos = get (tiHan, 'position'); % axis x, y value of title position

"Paul Quinn" wrote in message <kpamuh$ntf$1...@newscl01ah.mathworks.com>...

Pw

unread,
Mar 28, 2014, 3:48:08 PM3/28/14
to
"David Strozzi" <dstr...@mit.NOSPAM.edu> wrote in message <eeef4...@webx.raydaftYaTP>...
A really simple way is to make a two lined title

title({'My Data Plot', ''})

This isn't automated but I'm sure you could write it into function. Plus, there is no issue with zooming, saving, or figuring out the position.

Hope this helps
PW

Pw

unread,
Mar 28, 2014, 3:49:08 PM3/28/14
to
"David Strozzi" <dstr...@mit.NOSPAM.edu> wrote in message <eeef4...@webx.raydaftYaTP>...

Daniel R.

unread,
Jan 26, 2017, 11:44:07 PM1/26/17
to
Very creative solution PW, thanks!

"Pw" wrote in message <lh4jnk$3a7$1...@newscl01ah.mathworks.com>...
0 new messages